The following equation has solutions x = 0 and x = 1.

##x=x^2##

This next equation has solutions x = -2 and x = 2.

##x^2=4##

but if we replace x^2 (in the second equation) with x from the first equation, we get the equation

##x=4##

which is incorrect. I believe correct use of substitution would should that there are no solutions to the system of equations.

Why is this substitution incorrect, and when can we validly substitute parts of one equation into another equation.