Consider a $2 \times 2$ matrix
$$ A= \left[\begin{array}{c} 2 & 7\\ 1 & 8\end{array}\right] $$
For this matrix, or for any $2 \times 2$ matrix $A$, why does $A^2 - \mbox{tr}(A) \cdot A + \det(A) I = 0$?
Some of my findings:
While looking for an answer in google, I found that the characteristic equation of a $2 \times 2$ matrix is almost similar to the equation I've given above. The characteristic equation is $$\lambda^2 - \mbox{tr}(A) \cdot \lambda + \det(A) I=0$$ where $\lambda$ is the eigenvalue of the matrix $A$. Being curious I computed the eigenvalue of the above matrix $A$ and found that $\lambda=9,1$ and surprisingly also $\det(A) = 9$ and if I replaced $A$ (which is a matrix) of this equation $A^2 - \mbox{tr}(A) \cdot A + \det(A) I = 0$ by determinant of the matrix $A$ then also the equation satisfies $|A|^2 - \mbox{tr}(A) \cdot \det(A) + \det(A) I=0$ and I understand the reason of this is $|A|=\lambda$.
But I cannot comprehend why $A^2 - \mbox{tr}(A) \cdot A + \det(A) I=0$ is true in general where $A$ is a matrix and $\lambda$ is a constant number and also why this is only true for $2 \times 2$ matrix and is there any relationship between this equation and characteristic equation?
PS: I am not much familiar with linear algebra, so much humble request is to you to keep your explanation within "matrix and determinants" domain as much as possible.
This is a special case of the general Hamilton-Cayley theorem: if $$ p_A(x)=a_0+a_1x+\dots+a_nx^n=\det(A-xI) $$ is the characteristic polynomial of the (square) matrix $A$, then $$ a_0I+a_1A+\dots+a_nA^n=0 $$ (the zero matrix).
In the case of a $2\times2$ matrix the characteristic polynomial is $$ \det\begin{bmatrix} a_{11}-x & a_{12} \\ a_{21} & a_{22}-x \end{bmatrix} =x^2-(a_{11}+a_{22})x+(a_{11}a_{22}-a_{12}a_{21}) =x^2-\operatorname{Tr}(A)x+\det(A) $$ There is no need to prove the general theorem: for a $2\times 2$ matrix, just plug in and look what happens.
For instance, the entry at positiion $(1,1)$ of $A^2$ is $$ a_{11}^2+a_{12}a_{21} $$ and so in $A^2-\operatorname{Tr}(A)A+\det(A)I$ we get $$ a_{11}^2+a_{12}a_{21}-(a_{11}+a_{22})a_{11}+a_{11}a_{22}-a_{12}a_{21}=0 $$ as you can easily verify. Similarly for the other entries.