Eigenvalues of a self-adjoint operator necessarily distinct?

Let's say we have a self-adjoint operator acting on an inner product space (real or complex), represented, of course, by a self-adjoint matrix.

I'm looking at the proof for spectral theorem in which you build up a basis out of eigenvectors relying on the fact that the characteristic polynomial will always have roots, both over a real and over a complex field, because eigenvalues of a self-adjoint operator are real.

But what I do not understand is, why do all eigenvalues must necessarily be distinct? How do we conclude that?

After all, spectral theorem says that every self-adjoint operator is always diagonalizable and I know that for a matrix of order $n$ to be diagonalizable, it has to have $n$ distinct eigenvalues.

So, what am I missing here?

Edit: A matrix doesn't have to have n distinct eigenvalues in order to be diagonalizable, but if it does have n distinct eigenvalues it is diagonalizable, guess I was too sloppy and tired to notice such a silly mistake! But I'm leaving the question here ^_^

The identity matrix is self-adjoint and all of its eigenvalues are equal (to $1$). The problem is in your false understanding that for a matrix to be diagonalizable, it has to have $n$ distinct eigenvalues ($n$ being the relevant dimension). That is in incorrect, as the identity matrix (and many others) show. You are probably confused with the true statement that if an $n\times n$ matrix has $n$ distinct eigenvalues, then it is diagonalizable.