Claim: For any matrix, the number of non-zero eigenvalues – including algebraic multiplicity – seems to always be equal to the rank of the matrix. Here is a non-counterexample:
\begin{bmatrix} 3 & 0 & 0 \\ 0 & 3 & 0 \\ 0 & 0 & 3 \end{bmatrix}
The above matrix has an eigenvalue of 3 with an algebraic multiplicity of 3. The rank is also three. I have read about this topic: What is the relation between rank of a matrix, its eigenvalues and eigenvectors
However, I see a few people use this counterexample:
\begin{bmatrix} 0 & 1 \\ 0 & 0 \end{bmatrix}
They claim: (1) the rank is 1, and (2) the eigenvalue is 0 with an algebraic multiplicity of 2. I dispute the latter.
Why not just switch row 1 and row 2?
Is there something illegal about that? Then the rank would still be 1 and the eigenvalues would be 1 and 0. Thus, the claim that the number of non-zero eigenvalues is the rank of a matrix holds true.
Is there a better counterexample matrix that disproves my original claim?
Because that changes the eigenvalues, their multiplicities (geometric and algebraic), and the eigenspaces. Elementary row operations do not preserve eigenanythings. Note that $1$ is now an eigenvalue, and $0$ is now has multiplicity $1$.
Fun fact: what does work is, for every elementary row operation you perform, you perform immediately afterwards the corresponding inverse elementary column operation! For example, if you multiply the $i$th row by $\alpha \neq 0$, then divide the $i$th column by $\alpha$. This will actually preserve eigenvalues (but not eigenvectors).
So, in your example, after swapping the rows, if you swap the columns, you get $$\begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}$$ which is another counterexample with rank $1$ and eigenvalue $0$ with multiplicity $2$.