# AB is similar to BA even though neither A nor B is invertible

I've read that $$AB$$ is similar to $$BA$$ if $$A$$ or $$B$$ were invertible. However in the case of $$A = \begin{pmatrix} 1 & 2 \\ 0 & 0 \end{pmatrix}$$ $$B = \begin{pmatrix}0 & 0 \\3 & 4\end{pmatrix}$$

$$AB = S^{-1}(BA)S$$ with $$S= \begin{pmatrix} 0 & -4/3 \\ 1 & 2\end{pmatrix}$$

is there another condition that describes when $$AB$$ is similar to $$BA$$ ?

Yes, if both $$AB$$ and $$BA$$ are diagonalisable. Since $$AB$$ and $$BA$$ always have the same spectra (a result discovered by Sylvester), if they are diagonalisable, they are similar to the same diagonal matrix and hence they are similar to each other.
In particular, if one of $$AB$$ or $$BA$$ has distinct eigenvalues, so must the other. Hence the two products are similar.
In your case, $$AB$$ is an upper triangular matrix that has two distinct eigenvalues $$6$$ and $$0$$. Therefore it is similar to $$BA$$.