How to find coordinates of 3rd vertex of a right angled triangle when everything else is known?

If you always want the $(x-x_1,y-y_1)$ vector to be rotated $90°$ counter-clockwise against the $(x_2-x_1,y_2-y_1)$ one, then you have

\begin{align*} n(x-x_1) &= m(y_1-y_2) \\ n(y-y_1) &= m(x_2-x_1) \end{align*}

So the left $y$ difference is the right $x$ difference, and the left $x$ difference is the negative of the right $y$ difference. This amounts to the $90°$ rotation I mentioned.

Solve the above and you find

\begin{align*} x &= \frac{m(y_1-y_2)}n+x_1 \\ y &= \frac{m(x_2-x_1)}n+y_1 \end{align*}

which corresponds to one of your four solutions.