I've learnt that the square root of a number squared is equal to the absolute value of that number, but I haven't really understood why. I have looked through other questions on MSE but didn't really find a good answer.
As an example: for me there are two ways to arrive at a solution for $\sqrt{(-5)^2}$
First: $\sqrt{(-5)^2}= $ $\sqrt{25}=5$
Second: $\sqrt{(-5)^2}= $ $\ (-5)^{\frac{2}{2}}$$\ =(-5)^1=-5$
but according to the $\sqrt{x^2} = | x | $ rule 5 is the only solution. What is the flaw in my logic in getting -5 as a solution. I would really appreciate a comprehensive explanation that clears this up. Thanks in advance.