Solutions of sin(x) = cos(x) I know that the solutions to the equation $\sin(x) = \cos(x)$ are :
$ x= \frac{\pi}{4}$  (45°) ; $ x= \frac{5 \pi}{4}$ (225°)
However when I try to solve it algebraically I get the following :
$$  \sin x = \cos x$$
$$  \sin^2 x = \cos^2 x$$
$$  \sin^2 = 1 - \sin^2 x$$
$$  2\sin^2 x = 1$$
$$  sin^2 x = \frac{1}{2}$$
$$ \sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$
$$ \sqrt {sin^2 x} = \sqrt{\frac{1}{2}}$$
$$ \sin x= \lvert\frac{1}{\sqrt2}\rvert$$
$$ \sin x= \frac{\sqrt2}{2}  ;  \sin x= -\frac{\sqrt2}{2}$$
So if I look for all the values of $x$ that solve the above I should get not only $ x= \frac{\pi}{4}$  (45°) ; $ x= \frac{5 \pi}{4}$ (225°) but also $ x= \frac{3\pi}{4}$  (135°) ; $ x= \frac{7 \pi}{4}$ (315°).
What am I doing wrong?

The issue :
when you write out $\sin x = \cos x$ implies $\sin^2 x = \cos^2  x$, there is no problem with the implication. However, an implication leads to a weaker statement, which may admit "extraneous" solutions. For example, the above implication is got by multiplying by squaring both sides, but then that ends up including the case when $\sin x = -\cos x$.
Therefore you need to ensure that your implications are both ways, so that the solutions of both equations are retained, or you have to eliminate extraneous solutions once you reach the end.
The two extraneous solutions  $\frac{3\pi}4 , \frac{7\pi}4$ obtained are of the equation $\sin x = -\cos x$, which got included as solutions of the equation $\sin^2 x = \cos^2 x$ when you moved to this statement from the one you were given.
