The question actually asks how many ways are there to find a collection of $p$ elements of which it contains exactly $q$ elements from $A$ and the rest from $B$. Obviously $q\le m$ and $p\le (m+n)$.
Here, $|A|=m, ~|B|=n$
So, there are $\begin{pmatrix} m\\ q \end{pmatrix}$ ways to find $q$ elements from the set $A$
and the rest $(p-q)$ elements can be chosen from the $B$ which has $\begin{pmatrix} n\\ p-q \end{pmatrix}$ ways.
$\therefore~$The required number of ways $=\begin{pmatrix} m\\ q \end{pmatrix}\times\begin{pmatrix} n\\ p-q \end{pmatrix}$.
So the correct answer is C.