Consider a problem of minimizing $f(x)$ under the constraint that $g(x)=0$. The standard approach is to use Lagrange multiplier $$\mathcal L = f(x) -\lambda g(x)$$ and differentiate $\mathcal L$ to get $$f'(x) - \lambda g'(x) = 0.$$ Now, $g(x) =0$ is equivalent to $g^2(x) = 0$. So it seems we can consider the latter constraint instead, obtaining $$\mathcal L = f(x) -\lambda g^2(x)$$ and then $$f'(x) - 2\lambda g(x) g'(x)= 0.$$ But we know that $g(x)=0$ so this can be simplified to $$f'(x)=0$$ ...which does not make any sense: the constrained solution obviously does not need to satisfy $f'(x)=0$.
Where is the mistake in this reasoning?
The Lagrange multiplier condition really says that the gradient of $f$ should be parallel to the gradient of $g$. If you replace $g$ by $g^2$ then you are requiring that the gradient of $f$ is now parallel to the zero vector, which all vectors are, so everything is fine geometrically speaking. This case is really not correctly handled by putting $\lambda$ on $\nabla g$, as multivariable calculus books usually do. It is correctly handled if you put $\lambda$ on $\nabla f$, but then cases where $\nabla f$ vanishes are lost instead.