Consider the matrix \begin{equation} \begin{pmatrix}1 & 1 & 1\\ 1 & 1 &1\\ 1 & 1 &1\end{pmatrix}.\end{equation} The rank of this matrix is $1$ which is less than $3$. So all three eigenvectors are not linearly independent. Therefore, it seems that $A$ cannot be diagonalized by a similarity transformation $S^{-1}AS$ since $S$ is not invertible.
However, the minimal polynomial of $A$ has simple roots. They are $0$ and $3$. Hence, according to the condition of diagonalizability, this should diagonalizable.
Why am I arriving at such a contradiction? Where am I making a mistake?
The eigenvalues are $\{3,0,0\}.$ So $0$ is a degenerate eigenvalue, and not a simple root of the characteristic polynomial. What is the dimension of its corresponding eigenspace? According to Mathematica, the eigenvalues corresponding to $\{3,0,0\}$ are: $$\left\{\left[\begin{matrix}1\\1\\1\end{matrix}\right],\left[\begin{matrix}-1\\0\\1\end{matrix}\right],\left[\begin{matrix}-1\\1\\0\end{matrix}\right]\right\}. $$ As these are clearly linearly independent, the geometric multiplicity of the eigenspace corresponding to $\lambda=0$ is therefore $2,$ making your matrix diagonalizable.