Why isn't the definition of absolute value applied when squaring a radical containing a variable?
$$\left(\sqrt a\right)^2\ne\sqrt{a^2}.$$
Try with $a=-1$.
Indeed, $\sqrt{a^2}=\lvert a\rvert$. But $\sqrt a^2=a$ (assuming that $a\geqslant0$), not $\lvert a\rvert$.
From the fact that you can take $\sqrt {5-x}$ you know that $5-x \ge 0$ so you don't need the absolute value signs.