Given that matrix $A$ is diagonalizable and has eigenvalues of $0$ or $1$, show that $A^2 = A$ Suppose that $A$ is a diagonalizable $n \times n$ matrix such that the characteristic polynomial of $A$ is $p(λ)=λ^k(1−λ)^{n−k}$, where $k$ is a positive integer such that $0≤k≤n$.
I want to prove $A^2=A$. I know that for this, I'll need to prove that for any eigenvector $v$, $A^2 v=Av$. I tried setting up my proof like this:
Since $A$ is diagonalizable, there exists an invertible matrix $P$ such that $A=P^{-1}DP$, where $D$ has all the eigenvalues of $A$ on its diagonal. But since every eigenvalue is either $0$ or $1$, $D= \lambda I$. From there, we get:
$$A = P^{-1}DP = P^{-1}(\lambda I_n)P = (\lambda I_n)(P^{-1}P) = \lambda I_n$$
$$ \implies A \times A = (\lambda I_n) \times (\lambda I_n) = \lambda ^2$$
All I've succeeded in doing here is showing $A^2 = \lambda ^2$. How can I show also that $A^2 = A$? Any guidance is greatly appreciated!

Since $ A $ is diagonalizable, you can rewrite it as $ A = PDP^{-1} $, so, by associativity of matrix multiplication
$$ A^2 = A \cdot A = (PDP^{-1}) \cdot (PDP^{-1}) = PD \cdot (P^{-1}P) \cdot DP^{-1} = PD^2 P^{-1} $$
Now it’s left to calculate what $D^2$ is.
I won’t go in the details, it depends on the level of formality required, but it’s not difficult to get convinced that the product of two diagonal matrices is still a diagonal matrix. Moreover, the following property holds: given two diagonal matrices $S$ and $D$, one can use the compact notation for diagonal matrices and write only the elements on the diagonal $$S = \mathrm{diag}(a_1, \dots, a_n), \quad D= \mathrm{diag}(b_1, \dots, b_n)$$ then, the product of the matrices is the product of the elements. $$ D\cdot S = \mathrm{diag}(a_1\cdot b_1, \dots, a_n \cdot b_n)$$
Specifically, in your case, A has eigenvalues of either 0 or 1, and your $ D $ is the spectral matrix, the diagonal matrix that has the eigenvalues on the main diagonal. So when you write D with the compact notation, the entries in that “$ \mathrm{diag} $ vector” will only be either 0 and 1, and when you calculate $ D^2 $, since the entries will be the same, in every entry you’ll either do $0\cdot0=0$ or $1\cdot 1 =1 $. So, in the end, $D^2 = D $.
We left ourselves saying that $ A^2 = PD^2 P^{-1} $, so  $ A^2 = PDP^{-1} $, but $ A = PDP^{-1} $by hypothesis. In the end $ A^2 = A $.
