Why a (general) block matrix does not have the same eigenvalues of the first block?

Based on the next relation:

$$\det\begin{bmatrix}A & B \\ C & D\end{bmatrix} = \det(A)\det(D - CA^{-1}B),$$

I have that for computing the eigenvalues of the block matrix:

$$\det\begin{bmatrix}A-\lambda I & B \\ C & D-\lambda I\end{bmatrix} = \det(A-\lambda I)\det((D-\lambda I) - C(A-\lambda I)^{-1}B) = 0$$

So $\det(A - \lambda I) = 0$ says that the eigenvalues of $A$ are eigenvalues of the block matrix? But from some numerical simulations I have found that this is not true, what am I missing here? Maybe is because the first relation requires $A$ nonsingular and $A-\lambda I$ is not?

Then, this leads me to another question, why this expression holds $$\det\begin{bmatrix}A-\lambda I & 0 \\ C & D-\lambda I\end{bmatrix} = \det(A-\lambda I)\det((D-\lambda I) = 0$$ for stating that the eigenvalues of the block matrix are the eigenvalues of $A$ and $D$ if $A-\lambda I$ is singular?

Many thanks in advance.

If $\det(A - \lambda I) = 0$, then you cannot form $(A - \lambda I)^{-1}$, which appears also in the formula. Hence the formula does not apply, unless $B = 0$ or $C = 0$, the case of a block tridiagonal matrix.
I was about to ask the very same question when I found this one... I know that I'm two years late but this issue does intrigue me so I want to say that the formula in the question, although not valid in general, can be still useful in some situations to compute the eigenvalues of block matrix. In fact if $\lambda$ is an eigenvalue of $\begin{pmatrix} A & B\\ C & D\\ \end{pmatrix}$ then at least one of the following must be true:
1. $\lambda$ is an eigenvalue of $A$;
2. $\lambda$ is a solution of $\det(D - \lambda I - C(A-\lambda I)^{-1}B)=0$.
The proof of this fact is just the observation made in the question. I want to say that the condition 2 is NOT a polynomial in $\lambda$. I think that it's a rational function instead. Thus if it is wanted to compute the eigenvalues of the block matrix, one could just compute the roots of $\det(A - \lambda I)$, then the roots of the numerator of $\det(D - \lambda I - C(A-\lambda I)^{-1}B)$ and then manually check which one of those is an actual eigenvalue of the big matrix. Ok, I admit that it's not very efficient but perhaps in some special cases it could be useful.