Is the rank of a matrix equal to the number of non-zero eigenvalues?

Unfortunately, the answer is no in general, though the claim will hold true for diagonalizable matrices. Not all matrices are diagonalizable, including the matrix that you gave in your example. If your matrix is $n \times n$, then diagonalizability is equivalent to having a set of $n$ linearly independent eigenvectors, and those eigenvectors corresponding to non-zero eigenvalues will form a basis for the range of the matrix; hence rank is obtained (including multiplicities).

However, if you look at $A^T A$, then you can use the eigenvalues of that matrix to obtain the rank, regardless of what $A$ is. This is because $A^T A$ is symmetric, and thus must be diagonalizable, and furthermore one can show that $\mathrm{rank}(A^T A) = \mathrm{rank}(A)$.


rank of a matrix = number of non zero Eigen values

is not true, as you have witnessed.

Consider that $A^3=0$, so if $A$ has an eigenvalue $\lambda$ and $v\neq0$ is a corresponding eigenvector, then $$ 0=A^3v=\lambda^3v $$ meaning $\lambda^3=0$, so $\lambda$ must be $0$.

The rank is, however, equal to the dimension of the image. Which is to say, the size of the largest possible set of linearly independent vectors of the form $Av$.

It is also the case that nilpotency (or more specifically the fact that the image may contain elements of the kernel) is in some sense the only thing that can go wrong with your statement.