Let $\lambda\in\mathbb C-\{0\}$. Partition matrix $M$ as follows:
$$M=\left(\begin{array}\\I_m&A\\\lambda^{-1}B&I_n\end{array}\right).$$
Using determinant factorization property of Schur complements, we have
$$\begin{split}
|M|&=|I_m||M/I_m|\\
&=|I_n-\lambda^{-1}BI_m^{-1}A|\\
&=(-\lambda^{-1})^n|BA-\lambda I_n|\\
&=(-\lambda)^{-n}|BA-\lambda I_n|.\end{split}$$
Using the same factorization, we have
$$\begin{split}
|M|&=|I_n||M/I_n|\\
&=|I_m-AI_n^{-1}\lambda^{-1}B|\\
&=(-\lambda^{-1})^m|AB-\lambda I_m|\\
&=(-\lambda)^{-m}|AB-\lambda I_m|.\end{split}$$
As a result, we have $(-\lambda)^{-m}|AB-\lambda I_m|=(-\lambda)^{-n}|BA-\lambda I_n|$, which in turn implies $|AB-\lambda I_m|=(-\lambda)^{m-n}|BA-\lambda I_n|$. The last equation is called Weinstein–Aronszajn identity.
From Weinstein–Aronszajn identity, it is clear that $AB$ and $BA$ has the same set of non-zero eigenvalues. The remaining eigenvalues, if any, must be zeroes because otherwise it would already have been considered previously.