$\sqrt{x}$$\sqrt{x}$ = $x$ but $\sqrt{x^2}$ = $|x|$. Why? $\sqrt{x}$$\sqrt{x}$ = $x$ but $\sqrt{x^2}$ = $|x|$. Why is this?

I'm just learning algebra again after many years and I can't seem to figure out why this is. I'm sure this is trivial but if someone could explain it it would help me a lot. Thanks!
By definition $\sqrt x$ is the unique non-negative real number $y$ such that $y^2=x$, so $\sqrt x\cdot\sqrt x=x$ is true by definition. 

Now apply the definition to $\sqrt{x^2}$: $\sqrt{x^2}$ is the unique non-negative real number $y$ such that $y^2=x^2$. If $x=0$, the only real number whose square is $x^2$ is $0$, so of course $\sqrt{x^2}=0=|0|$. If $x\ne 0$, there are always two real numbers $y$ such that $y^2=x^2$: one of them is $x$, and the other is $-x$. Exactly one of these two is positive. Since we don’t know whether $x$ is positive or not, we don’t know which of them is positive, but we know that whichever it is, it’s $|x|$. Therefore $|x|$ is the unique positive real number such that $|x|^2=x^2$, and by definition $\sqrt{x^2}=|x|$.

As an example, suppose that $x=-3$. Then $x^2=9$, and the two real numbers whose squares are $9$ are $-3$ (i.e., $x$) and $3$ (i.e., $-x$). The non-negative one is $3=-(-3)=|-3|$. Had we started with $x=3$, $x^2$ would still have been $9$, and we’d still have wanted the positive one of $x$ and $-x$, but this time that would be $x$, not $-x$. It’s still true, however, that $|x|=|3|=3$, the one that we want.
I think your source of confusion here comes from thinking of $\sqrt{x}$ as a number rather than a function. Often times, we write something as $\sqrt{x}$ to denote the squareroot(s) of the number $x$. However, in many other situations, we also write $\sqrt{x}$ to talk about the function which sends the number $x$ to its square root.

In particular, in your example, the first instance $\sqrt{x}\sqrt{x} = x$, is most likely talking about the number $\sqrt{x}$. Indeed, by definition of the number $\sqrt{x}$, we have that equation. 

In the second instance, $\sqrt{x^2} = |x|$, it is more appropriate to think about $\sqrt{x}$ as a function, which is composed with the function $x^2$. In that case, $\sqrt{x}$ must be strictly positive, since there are no real numbers whose square roots are negative!