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?

Obviously $A\neq 0$, then $B=\frac{2}{A}$. Subtitute into the first equation:
$A^2+\frac{4}{A^2}=5 \implies 0=A^4-5A^2+4=(A^2-1)(A^2-4)$
Here we can deduce 4 values of $A$ like your solutions, find $B=\frac{2}{A}$ and it's done
