As clarified in the comments, the question can’t be answered without assuming a prior for $p$ and $q$, and the given solutions assume that $p$ and $q$ are uniformly and independently drawn from $[0,1]$.
This sort of problem is often easier to solve with symmetry arguments than with integrals. If you’re not yet familiar with this technique, it might make sense to look at it applied in a somewhat simpler context, e.g. at How to prove the rule of succession without calculus?, before applying it to this problem.
The key observation is that tossing a coin with success probability $p$ can be replaced by uniformly and independently drawing a number from $[0,1]$, with success if the number drawn is less than $p$.
This allows us to reformulate the problem like this: Uniformly and independently draw $n_1+n_2+2$ numbers from $[0,1]$, the last two being $p$ and $q$. Given that $m_1$ of the $n_1$ numbers are less than $p$ and $m_2$ of the $n_2$ numbers are less than $q$, what is the probability that $p\lt q$?
In this formulation, the exact values of the numbers are irrelevant; all that matters is their order, and all orders are equiprobable by symmetry. So we can reformulate the problem further: Label one ball with $p$, one ball with $q$, $n_1$ balls with $1$ and $n_2$ balls with $2$. What is the probability that in a uniformly random permutation of these $n_1+n_2+2$ balls the ball labelled $p$ comes before the ball labelled $q$, given that $m_1$ balls labelled $1$ come before the ball labelled $p$ and $m_2$ balls labelled $2$ come before the ball labelled $q$?
This is not too difficult to calculate: If $q$ comes after $p$ and there are $k$ balls before $p$, and thus $n_1+n_2+1-k$ balls after $p$, then there are $\binom k{m_1}$ ways to choose the $m_1$ balls labelled $1$ that come before $p$ and $\binom{n_1+n_2+1-k}{n_1-m-1}$ ways to choose the $n-1-m_1$ balls labelled $1$ that come after $p$. (The position of $q$ among the remaining balls is then fixed by $m_2$.) Without the condition $p\lt q$, there are $\binom{n_1+n_2+2}{n_1+1}$ ways to choose positions for the $n+1$ balls labelled $p$ or $1$. (The positions of $p$ and $q$ are then fixed by $m_1$ and $m_2$, respectively.) Thus, the desired probability is
$$
\binom{n_1+n_2+2}{n_1+1}^{-1}\sum_{k=m_1}^{m_1+m_2}\binom k{m_1}\binom{n_1+n_2+1-k}{n_1-m_1}\;.
$$
I don’t think this sum can be simplified. For example, in your first case, with $n_1=2$, $m_1=1$, $n_2=4$, $m_2=3$, we have
$$
\binom{2+4+2}{2+1}^{-1}\sum_{k=1}^{1+3}\binom k1\binom{2+4+1-k}{2-1}=\frac{1\cdot6+2\cdot5+3\cdot4+4\cdot3}{8\cdot7}=\frac57\;,
$$
in agreement with your result.