Proving $\operatorname{rank}A =\operatorname{rank}B$ when $AB = 2A + 3B$
Let $x \in ker(B)$, then $0=ABx=2Ax+3Bx=2Ax$, hence $x \in ker(A).$
Thus $ker(B) \subset ker(A).$
Similar arguments give: $ker(A) \subset ker(B).$
Conclusion: $ker(B) =ker(A).$
The rank - nullity -theorem gives now the result.
We have
$$A(B-2I) = 3B$$
Since $B-2I$ is invertible, it follows that $\operatorname{rank} A = \operatorname{rank}(3B) = \operatorname{rank} B $.