I was trying a problem and was getting the wrong answer and when I saw the solution on the internet I found this statement written in square brackets $\sqrt{x^2}$[note square is on $x$] is $|x|$. Till now I have learned that by laws of exponents we can multiply the powers and obtain $\sqrt{x}^2$ as $x$. But this seems confusing to me. Please clear this doubt.
And does this apply to $\left({\sqrt x}\right)^2$[note square is on radical] i.e. is $\left({\sqrt x}\right)^2 = |x|$?