Quadratic equation system $A^2 + B^2 = 5$ and $AB = 2$ Given a system of equations

$A^2 + B^2 = 5$
$AB = 2$

what is the correct way to solve it?
I see immediately that the answers are

*

*$A=1, B=2$

*$A=2, B=1$

*$A=-1, B=-2$

*$A=-2, B=-1$
but I don't understand the correct way of getting there. I have tried to isolate one of the variables and put the resulting expression into one of the equations, but this didn't get me anywhere. What is the correct way of solving this problem?

From $AB=2$ we know $A$ and $B$ have the same sign.
Moreover, if we find a solution for some values $A=A_1$ and $B=B_1$,
then $A=-A_1$ and $B=-B_1$ also is a solution.
So we can assume initially that $A$ and $B$ are both positive,
find all such solutions, and then simply change signs to produce all the remaining solutions (the ones in which $A$ and $B$ are both negative).
Similarly, we can assume initially that $A\geq B$, because all the solutions
in which $B \geq A$ can then be produced just by swapping the values of
the two variables.
So we now have (with these assumptions) $A \geq B > 0,$ 
$A^2 + B^2 = 5,$ and $AB = 2.$ Then
\begin{align}
(A + B)^2 &= A^2 + 2AB + B^2 = 5 + 2(2) = 9, \\
(A - B)^2 &= A^2 - 2AB + B^2 = 5 - 2(2) = 1. \\
\end{align}
In each of these equations, the positive square roots of both sides 
must be equal, and since $A+B>0$ and $A-B\geq0$ this tells us that
\begin{align}
A + B &= 3, \\
A - B &= 1. \\
\end{align}
Therefore (adding the two equations) $2A = 4,$ so $A = 2,$ so $B = 1.$
That is, the unique solution (under the assumption $A\geq B>0$)
is $(A,B) = (2,1).$
We can now remove the assumptions that $A\geq B$ and that $B>0,$
then use the facts mentioned earlier to derive the remaining solutions:
$(A,B) = (1,2)$ (swapping values), $(A,B) = (-2,-1)$
or $(A,B) = (-1,-2)$ (changing signs).
