Linear operator T on $ \mathbb{R}^5$. $T^4 \neq 0$, but $T^5 = 0$. What's the rank of $T^2$?
If $$ T(\Bbb R^5)=\Bbb R^5\;, $$ this would imply $\ker T=0$ (from the well known formula $\dim\ker T+\dim\operatorname{Im}T=\dim\Bbb R^5=5$) and the OP pointed out that $\{0\}\neq T^4(\Bbb R^5)\leq\ker T$.
Thus $$ T^j(\Bbb R^5)=T^{j-1}T(\Bbb R^5)\lneq T^{j-1}(\Bbb R^5) $$ for every $j=2,\dots,5$.
So we get the following strict chain $$ \{0\}=T^5(\Bbb R^5)\lneq T^4(\Bbb R^5)\lneq T^3(\Bbb R^5)\lneq T^2(\Bbb R^5)\lneq T(\Bbb R^5)\lneq\Bbb R^5 $$ from which it immediately follows that $$ \operatorname{rk} T^2=3\;. $$
Note that:
[a] If $U$ is any nontrivial subspace of $\mathbb{R}^5$ such that $T(U) \subset U$, then $T(U) \subsetneq U$.
and that
[b] For linear subspace $U \subsetneq V$, dim$U$ < dim $V$.
Thus, $5=$dim $\mathbb{R}^5$ >dim $T$($\mathbb{R}^5$) >dim $T^2$($\mathbb{R}^5$) >dim $T^3$($\mathbb{R}^5$) >dim $T^4$($\mathbb{R}^5$) >dim $T^5$($\mathbb{R}^5$)$=0$.
You have only one choice for each dimension dim$T^i$($\mathbb{R}^5$).