I'm editing the post after johnny10 pointing out my mistake in the previous post.
If we denote for fix $k$:
$V_k= \{x\in \mathbb{C}^m | (BA-\lambda I_m)^k x=0 \}$
and
$W_k= \{x\in \mathbb{C}^n | (AB-\lambda I_n)^k x=0 \}$
then $\dim V_k =\dim W_k$.
For the proof, I just extend the answer that johnny10 gave above (but the comment doesn't allow me to type too many things so I make a post here):
The following is the same as that given by Christiaan Hattingh in the post with adapted size:
From $\begin{bmatrix} I_n & -A \\ 0 & I_m\end{bmatrix}\begin{bmatrix} AB & 0 \\ B & 0\end{bmatrix}\begin{bmatrix} I_n & A \\ 0 & I_m\end{bmatrix} = \begin{bmatrix} 0 & 0 \\ B & BA\end{bmatrix}$, we see that $\begin{bmatrix} AB & 0 \\ B & 0\end{bmatrix} \text{ and } \begin{bmatrix} 0 & 0 \\ B & BA\end{bmatrix}$ are similar so they have same Jordan form.
In particular, $\text{rank}\left (\begin{bmatrix} AB & 0 \\ B & 0\end{bmatrix} - \lambda I_{m+n}\right )^k = \text{rank}\left (\begin{bmatrix} 0 & 0 \\ B & BA\end{bmatrix} - \lambda I_{m+n}\right )^k$ for all $k$.
On the other hand, we have $\text{rank}\left (\begin{bmatrix} AB & 0 \\ B & 0\end{bmatrix} - \lambda I_{m+n}\right )^k = \text{rank}\left (\begin{bmatrix} (AB-\lambda I_n)^k & 0 \\ D & (-1)^k \lambda^k I_m\end{bmatrix} \right ) = \text{rank}(AB - \lambda I_n)^k +m$
and
$\text{rank}\left (\begin{bmatrix} 0 & 0 \\ B & BA\end{bmatrix} - \lambda I_{m+n}\right )^k = \text{rank}\left (\begin{bmatrix} (-1)^k \lambda^k I_m & 0 \\ D' & (-1)^k (BA-\lambda I_m)^k\end{bmatrix} \right ) = \text{rank}(BA - \lambda I_m)^k +n$
Therefore, $n-\text{rank}(AB - \lambda I_n)^k=m-\text{rank}(BA - \lambda I_m)^k$ for all $k$ and it implies the statement above.
Hence, $\dim V =\dim W $ since in general $V$ and $W$ are just $V_k$ and $W_k$ for $k$ large (we can take $k$ to be the algebraic multiplicities).
\dimso the title renders correctly :) – talbi Feb 22 '21 at 08:18