Given $A$ is nilpotent, means there exists a real k such that $A^m=0$ for all $m\ge k$ and $A^p\ne0$ for all $p\lt k$.
So you have initial equation $A^2B-2ABA+BA^2=0$.
Now left multiply the equation both sides by $A^{k-2}$.
You get : $0+2A^{k-1}BA+A^{k-2}BA^2=0$.
Now,take $A^{k-2}$ common. Since it is non zero, the other part has to be zero.
So $2ABA+BA^2=0$. Now you right Multiply both sides by $A^{k-2}$. Now you get $2ABA^{k-1}=0$. Following similar argument,you conclude $AB=0$. So obviously,$AB$ is nilpotent as $(AB)^k=0$ for any $k\ge1$