If the rank of $A$ is equal to the number of non-zero eigenvalues, do $A$ and $A^2$ have the same rank?

Let $J= \operatorname{diag}(J_1,...,J_k)$ be the Jordan normal form.

Note that $J^2= \operatorname{diag}(J_1^2,...,J_k^2)$

The rank of $J$ is given by the sum of the ranks of the blocks that is, $\operatorname{rk} J = \sum_k \operatorname{rk} J_k$. Similarly, $\operatorname{rk} J^2 = \sum_k \operatorname{rk} J_k^2$.

It follows from the hypothesis that the rank of the Jordan block corresponding to the zero eigenvalue is zero. That is, the Jordan block is identically zero (and so is the square of the Jordan block).

For the blocks $J_k$ corresponding to non zero eigenvalues, we have $\operatorname{rk} J_k = \operatorname{rk} J_k^2$.

It follows that $\operatorname{rk} J = \operatorname{rk} J^2$.

Alternative:

Let $N = \ker A$. We see that $z=\dim N$ is the number of zero eigenvalues of $A$. Let $b_1,..,b_z$ be a basis for $N$ and complete the basis with $b_{z+1},...,b_n$. Note that $N$ is $A$ invariant and so in this basis, $A$ has the form $\begin{bmatrix} 0 & A_{12} \\ 0 & A_{22}\end{bmatrix}$. Furthermore, we must have $\det A_{22} \neq 0$ otherwise $A$ would have more that $ z$ zero eigenvalues.

Then we want to show that $\ker A^2 = N$. Note that $A^2$ has the form $\begin{bmatrix} 0 & A_{12}A_{22} \\ 0 & A_{22}^2\end{bmatrix}$ and it follows from this that if $x \in \ker A^2$ then $x \in \ker A$.