If $\operatorname{rank} (AB) = \operatorname{rank} (BA)$ for any $B$, then is $A$ invertible?
If $A$ is not invertible, there is a nonzero vector $u$ in the null space of $A$. Also, since you assume $A \neq 0$, there is a nonzero vector $v$ in the column space of $A$. Use these observations to construct a rank one matrix $B$ such that $AB = 0$ and $BA \neq 0$.