This is exercise $4.6$ on page $154$ of the textbook Algebra: Chapter $0$ (authored by P. Aluffi):
Let $I,J$ be ideals of a commutative ring $R$. Assume that $R/(IJ)$ is reduced (that is, it has no nonzero nilpotent elements). Prove that $IJ = I \cap J$.
This is how I tried (knowing that $IJ \subseteq I \cap J$ since $ij \in I$ and $ij \in J$, and since $I \cap J$ is an ideal, it is closed under addition):
If $R/(IJ)$ is reduced, then $\forall r \in R: \ r^n \in IJ \Rightarrow r \in IJ$.
Let $a \in I \cap J$. $a^2 = aa \in IJ$, since $a \in I$, but also $a \in J$. Then (since $R/(IJ)$ is reduced) $a \in IJ$.
Is it a right way? If yes, does it mean the commutativity hypothesis is not necessary, and it works for arbitrary rings? If not, where is the mistake?
The proof is correct and the statement doesn't indeed require $R$ is commutative.
What fails in the noncommutative case is that the set of nilpotent elements may not be an ideal, but it is not a problem here.
You may want to note that a ring has no (nonzero) nilpotent elements if and only if $a^2=0$ implies $a=0$, so the use of just $a^2$ in your proof is not surprising.