As WimC says, the eigenvalues of $\left( \begin{smallmatrix} x & 0 \\ 0 & y \end{smallmatrix} \right)$ collide in codimension one.
So this is not always a true statement.
On the other hand, let $H$ be the space of $n \times n$ Hermitian matrices, which is a real vector space of dimension $n^2$. Let $\Delta \subset H$ be the locus where two of the eigenvalues collide. Then $\dim \Delta = n^2 -3$. If we have a family of Hermitian matrices parameterized by some parameter set $B$, then we get a map $\phi: B \to H$ and we are interested in the dimension of $\phi^{-1}(\Delta)$. Generically, we should expect the image of $\phi$ to be transverse to $\Delta$, so we should expect $\phi^{-1}(\Delta)$ to be codimension $3$. I can't see where Wikipedia is getting the codimension $2$ number.
Computation of the dimension of $\Delta$: The unitary group $U_n$ acts on $H$ and $\Delta$ is a union of $U_n$ orbits. The subset of $\Delta$ where precisely two of the eigenvalues collide is dense in $\Delta$. So let's compute the dimension of the space where precisely two eigenvalues collide.
The space of matrices with eigenvalues $\lambda_1$, $\lambda_2$, ..., $\lambda_{n-2}$, $\mu$, $\mu$ is a $U_n$ orbit. The stabilizer of $\mathrm{diag}(\lambda_1, \lambda_2, \ldots, \lambda_{n-2}, \mu, \mu)$ is $U(1)^{n-2} \times U(2)$, of dimension $(n-2) + 4=n+2$. So the size of the orbit is $n^2 - n -2$. There are $n-1$ ways to choose the parameters $\lambda_1$, $\lambda_2$, ..., $\lambda_{n-2}$, $\mu$. So $\dim \Delta = (n^2-n-2)+(n-1) = n^2-3$.