Your error is in assuming that (x\^2)\^(1/2) = x; this only holds for positive x. There are a couple ways to see this - one is to simply note that sqrt(x\^2) = |x|, which is not equal to x for negative x.

A way that potentially gives more insight is that we can note that x\^2 can't admit an inverse on the whole real line. The graph fails the horizontal line test, so the "inverse" would not be a function (algebraically, this states the function x\^2 is not injective, so it cannot admit an inverse). However, if we restrict x\^2 to *only* the positive numbers, or *only* the negative numbers, then it is injective/it passes the verticla line test, so it does have an inverse on those restricted sets. For positive numbers, the inverse function of f(x) = x\^2 is g(x) = x\^{1/2}, and for negative numbers, the inverse function is h(x) = -x\^{1/2}, where we are taking x\^{1/2} to be the positive square root.

Because of this, when x is negative, we can't assume (x\^2)\^(1/2) = x, and so we don't get a contradiction that x = |x|.