https://matheducators.stackexchange.com/a/1400/775
Someone commented that the equation in the above answer might sometimes be correct after I commented a correction (feel free to rewrite it appropriately in the question title, my phone does not have a superscript 2). In what situations is this the case?
Expanding, $(x+3)^2=x^2+6x+9$. If this is equal to $x^2+9$, then $6x=0\implies x=0$ in the real numbers.
Alternatively, when "$6=0$", i.e., in $\mathbf{Z}_6,\mathbf{Z}_2$ and $\mathbf{Z}_3$, $6x=0\implies (x+3)^2=x^2+9\forall x$.