When I graph the function $f(x)=\sqrt{x}^2$ on Desmos, the output is the graph of the piecewise function $f(x)=x$, $x\ge0$; undefined otherwise.
I expected the graph of the absolute value function instead, because I thought that $\sqrt{x}^2 = \sqrt{x^2} = |x|$. Why are they not considered to be equal?
I'll add an answer, even though people in the comments have summed it up perfectly.
Negative numbers don't have square roots that are real numbers. This is why the function $f(x)=\sqrt{x}$ has the restriction $x\geq0$. As such, the function $f(x)=(\sqrt{x})^2$ will also have the restriction $x\geq0$.
When it comes to $f(x)=\sqrt{x^2}$, a restriction in the domain is no longer needed because $x^2$ will always be greater than or equal to zero regardless of whether $x$ is positive or negative.