The idea is to note that if $V$ is any subspace of $\mathbb{R}^p$, then the dimension of $W=\\{Av:v\in V\\}$ is at most $\dim(V)$. This follows from applying the Rank-Nullity Theorem to the restricted linear transformation $T:V\rightarrow\mathbb{R}^n$, $T(v)=Av$. Setting $V=range(B)$ and noting that $range(AB)$ then equals $W$, we get $rank(AB)\leq rank(B)$.
Since $range(AB)$ is a subspace of $range(A)$, we also have that $rank(AB)\leq rank(A)$.
Our findings give $rank(AB)\leq min(rank(A),rank(B))$.