Are the matrix products $AB$ and $BA$ similar? 
Given two matrices $A,B.$ On what conditions does $AB \sim BA$ hold?

 A: $AB$ is conjugate to $BA$ if either $A$ or $B$ are invertible. If neither is the case, there are counterexamples: for example, it may be the case that $AB = 0$ while $BA \neq 0$. Explicitly, take
$$A = \left[ \begin{array}{cc} 0 & 1 \\ 0 & 0 \end{array} \right], B = \left[ \begin{array}{cc} 0 & 0 \\ 0 & 1 \end{array} \right].$$
We have $AB = A$ but $BA = 0$. 
However, there is a salvage: $AB$ and $BA$ have the same characteristic polynomial. See this blog post. (Short proof: this must hold if either $A$ or $B$ is invertible, and that condition is Zariski dense.) 
A: As mentioned already, if either of $A$ or $B$ is invertible (and both are the same size), we have
$$
\begin{align}
AB=A(BA)A^{-1}\quad&\mbox{if $A$ is invertible}\\
AB=B^{-1}(BA)B\quad&\mbox{if $B$ is invertible}
\end{align}
$$
However, here is a short proof that even if $A$ is $m\times n$ and $B$ is $n\times m$, the characteristic polynomials of $AB$ and $BA$ differ only by a factor of $\lambda^{\large|n-m|}$.
A: If $A$ is invertible, then $AB = A(BA)A^{-1}$ which shows that $AB$ and $BA$ are similar. Similar (no pun intended) proof if $B$ is invertible.
A: The proof is rather straightforward and I do not assume anything about $A$ and $B$, except that they are square.
I do so by showing that they have the same eigenvalues. If that is the case then $A=MJM^{-1}$ and $B=CJC^{-1}$ both share the same $J$ in their Jordan form and I take for granted that there exist some matrix $K$ such that $C=KM$, in order to have $B=KMJ(KM)^{-1}$.
So suppose $\lambda$ is an eigenvalue of $AB$. Then $ABx=\lambda x$.
Premultiplying both sides by $B$, we get $BABx =BA(Bx) \lambda(Bx)$, which shows that $\lambda$ is also an eigenvalue of $BA$. 
