I found a description of the way to solve $$\frac{1}{a} + \frac{1}{b}=\frac{p}{q}$$, for relatively prime $p,q$ in integers that goes as follows:
Write the LHS as $\frac{a+b}{ab}$. Let $a=\frac{m+q}{p}, b=\frac{n+q}{p}$. Hence, $$\frac{a+b}{ab}=p\cdot \frac{m+n+2q}{q^2+(m+n)q+mn}=\frac{p}{q}$$. Thus, we see that the big fraction must be equal $\frac{1}{q}$. Thus, $q(m+n+2q)=q^2+(m+n)q+mn$, so $mn=q^2$. The solutions are generated as follows: list all ways to write $q^2$ as a product $mn$ of integers, keep only those for which $p$ divides $q+m$ and $q+n$ (since $a$ and $b$ are integers), and the solutions are $a=(m+q)/p$, $b=(n+q)/p$.
The only thing I don't understand is why we assume that $a=\frac{m+q}{p}, b=\frac{n+q}{p}$. This step seems completely arbitrary to me. Why do all solutions to the equation have this form? What is the motivation to make this substituiton?
For which coprime positive integers $p,q$ ($p<q$) does $$\frac{1}{a}+\frac{1}{b}=\frac{p}{q}$$ have a solution in distinct positive integers $a,b$ (the case $a=b$ works if and only if $p\le 2$) ?
Claim : There must be a divisor $t\mid q^2$ with $t<q$ such that $p\mid q+t$
Proof : Clearing the denominators gives
$$qa+qb=pab$$
Mutlplying with $p$ and rearranging gives
$$p^2ab-pqa-pqb=0$$
So, we have
$$(pa-q)(pb-q)=p^2ab-pqa-pqb+q^2=q^2$$
Hence $t:=pa-q$ is a divisor of $q^2$ , implying $p\mid q+t$. If $a$ and $b$ are distinct, the smaller divisor is smaller than $q$.
QED
This condition is also sufficient :
Assume, $t<q$ is a divisor of $q^2$ such that $p\mid q+t$.
Then $$pa-q=t$$ can be satisfied with the positive integer $a:=\frac{q+t}{p}$. It remains to show that for the cofactor $\frac{q^2}{t}$ , the corresponding $b$ is also a positive integer : We have $$\frac{\frac{q^2}{t}+q}{p}=\frac{q}{t}\cdot \frac{q+t}{p}$$ $p$ and $t$ are coprime because $q$ shares each common factor of $p$ and $t$ , but $p$ and $q$ are coprime. Since $t$ and $p$ both divide $q^2+qt$ , the product divides it as well. Because of $t<q$ , we finally have $a<b$