"If $A^2-2AB+B^2=0$, then $(A-B)^2=0$" is true. How about $n$-th degree case? I've known the following question:
Supposing that $A, B$ are the second degree square matrices whose elements are all complex numbers, then is the following true ?
If $A^2-2AB+B^2=O,$ then $(A-B)^2=O$ where $O$ is a zero matrix.
Surprisingly, the answer is Yes!
Proof : We'll use the fact that $\operatorname{trace} (AB)= \operatorname{trace}(BA)$.
Letting $C=A-B$, then $B=A-C$.
So,
$$A^2-2AB+B^2=0\rightarrow C^2=CA-AC \tag{1}$$
Hence,
$$\operatorname{trace} (C^2) = \operatorname{trace} (CA)-\operatorname{trace} (AC)=0 \tag{2}$$
Here, supposing that there exists $C^{-1}$, then multiplying $C^{-1}$ to $(1)$ from both sides leads 
$$I=AC^{-1}-C^{-1}A$$
where $I$ is a unit matrix. Then trace $(I)=\operatorname{trace} (AC^{-1})- \operatorname{trace} (C^{-1}A)$ leads a contradiction $2=0$. Then, knowing that there doesn't exist $C^{-1}$, we get det$(C)=0$.
By Cayley-Hamilton theorem,
$$C^2-\operatorname{trace}(C)C+\det (C)I=O\rightarrow C^2=\operatorname{trace}(C)C \tag{3}$$
Hence $(2)$ leads $0=\operatorname{trace}(C^2)=\operatorname{trace}(C)\times\operatorname{trace}(C)\rightarrow\operatorname{trace}(C)=0$.
Hence $(3)$ leads $C^2=O$. Now the proof is completed.
Let us call the above question the $2$nd degree version question. I got interested in this question. So, I've been thinking the $3$rd degree version question.
The $3$rd degree version question : Supposing that $A, B$ are the third degree square matrices whose elements are all complex numbers, then is the following true ?
If $A^3-3A^2B-3AB^2-B^3=O,$ then $(A-B)^3=O$ where $O$ is a zero matrix.
After struggling to solve this question, I got a counterexample.
The answer for the $3$rd degree version question is NO. The following is the counterexample:
$$A=\begin{pmatrix}
        0 & 0 & 0 \\
        1 & 0 & 0 \\
        0 & 0 & 0 \\
        \end{pmatrix}
,\ \ B=\begin{pmatrix}
        0 & 1 & 0 \\
        0 & 0 & 0 \\
        0 & 0 & 0 \\
        \end{pmatrix}.$$
I've tried to solve the $n$-th degree version question for $n\ge4$, but I'm facing difficulty. Then, here is my question.
Question : Could you show me how to solve the $n$-th degree version question for $n\ge4$?

Your counterexample $A=e_2e_1^T$, $B=e_1e_2^T$ for $n=3$ extends to $n\ge 3$ easily. Since $A^2=B^2=O$ any summand in $A^n+\ldots +(-1)^{n-k}{n\choose k}A^kB^{n-k}+\ldots +(-1)^nB^n$ is $O$ because $k\ge2$ or $n-k\ge2$. On the other hand, $A-B$ has $e_1-e_2$ as an obvious eigenvector of eigenvalue $-1\ne0$.
