When are we allowed to cancel factors from the characteristic equation of matrix? Let: $$ A = \left[ 
    \begin{matrix}
    1 & 2 & 2 \\
    2 & 1 & 2 \\
    2 & 2 & 1 \\
    \end{matrix}\right ]
$$
The characteristic equation of this matrix is: $(\lambda +1) (\lambda^2 -4\lambda -5) = 0$
$\implies (A+I)(A^2- 4A -5I) = 0$
But $AB = 0 \require{cancel} \cancel\implies A= 0$ or $B= 0$
But in this case, on solving we can clearly see that $A^2 - 4A - 5A = 0$ (0 denotes null matrix)
So, when does this work? When are we allowed to get cancel factors? In another question I did yesterday, cancelling the factor from the characteristic equation gave me the wrong answer. 
 A: Let's review the zero product property:
$$xy = 0 \implies x = 0 \text{ or } y = 0.$$
It holds in fields, such as $\mathbb{R}$ or $\mathbb{C}$ because non-zero numbers always have a multiplicative inverse. So, if $x \neq 0$, then
$$xy = 0 \implies x^{-1}xy = x^{-1}0 \implies y = 0.$$
(Or $x = 0$, in which case we were done before we even started.)
Matrices don't have this property you can have non-zero matrices that do not have inverses. In fact, if a matrix $A$ does not have an inverse, then there exists a non-zero matrix $B$ such that $AB = 0$. To prove this, consider a non-invertible matrix $A$. Then $\operatorname{ker} A \neq \lbrace 0 \rbrace$, so there must be a non-zero column vector $v$ such that $Av = 0$. If you form $B$ by simply putting $v$ into all of its columns, you get $AB = 0$.
So, $AB = 0 \implies A = 0 \text{ or } B = 0$ if and only if $A$ or $B$ is invertible.
A: In general $AB=0$ does't imply $A=0$ or $B=0$. In your case, that factor is corresponding to a minimal polynomial and note that the minimal polynomial is the smallest degree polynomial satisfied by $A$ .
For,  here the  matrix is diagonalizable so the minimal polynomial is a distinct linear factors which is exactly $$(x+1)(x-5)$$ and so $$(A+I)(A-5I)=A^2-4A-5I=0$$ 
