Eigenvalues are roots of characteristic polynomial. We want to find the connction between characteristic polynomials of AB and BA. Let $\chi_M(x)$ denotes a characteristic polynomial $\chi_M(x) = det(x - M)$
Lets prove the fact: For square matrices $A$ and $B$ holds $det(AB - x) = det(BA - x) \Leftrightarrow \chi_{AB}(x) = \chi_{BA}(x)$.
If $det(A) \neq 0$ then it follows from $det(AB - x) = det(A^{-1}A)det(AB - x) = det(A^{-1})det(AB - x)det(A) = det(BA - x)$.
If $det(A) = 0$ there are finite number of such $s \in \mathbb R$ that $\chi_A(s)=0$ because $\chi_A(s)$ is a finite-degree polynomial. Then there are infinite number of such $s$ that $\chi_A(s) \neq 0$. For all such $s$ we know $\chi_{(A-s)B}(x) = \chi_{B(A-s)}(x)$ as a result of a previous case. For every fixed $x$ we see two finite-degree polynomials ($x$ is fixed, $s$ is variable) $\chi_{(A-s)B}(x)$ and $\chi_{B(A-s)}(x)$ which are equal in infinite number of points. Then we conclude they are equal at every $s$. At $s = 0$ we get the result $\chi_{AB}(x) = \chi_{BA}(x)$ at every $x$.
For square matrices we are done!
Key fact (proof below): If $A$ is $m\times n$, $B$ is $n\times m$ and $n \geq m$ then $\chi_{BA}(x) = \lambda^{n-m}\chi_{AB}(x)$.
Consider $n\times n$ matrices $A' = \left(\dfrac{A}{0}\right)$ and $B' = (B\mid0)$. We just put zero rows and columns to make matrices $n\times n$.
First, $B'A' = BA \Rightarrow x - B'A' = x - BA \Rightarrow \chi_{B'A'}(x) = \chi_{BA}(x)$
Second, $A'$ and $B'$ are square matrices. Then due to the fact above we have $\chi_{B'A'}(x) = \chi_{A'B'}(x)$.
Third, $\chi_{A'B'}(x) = det(x - A'B') = det\begin{pmatrix}x - AB & 0 \\ 0 & \begin{matrix}x & 0 & \ldots & 0 \\ 0 & x & \ldots & 0 \\ \vdots & \vdots & \ddots & \vdots \\ 0 & 0 & \ldots & x \\\end{matrix}\end{pmatrix} = det(x - AB)x^{n - m} = x^{n-m}\chi_{AB}(x)$
So, we see $\chi_{BA}(x) = \chi_{B'A'}(x) = \chi_{A'B'}(x) = x^{n-m}\chi_{AB}(x)$. Then wee see all eigenvalues of $AB$ are eigenvalues of $BA$ and other $n-m$ eigenvalues are zeros in $BA$.