If $A$ and $B$ are two matrices such that $AB=B$ and $BA=A$ then how to show that $A^2+B^2$ equals $A+B$? 
If $A$ and $B$ are two matrices such that $AB=B$ and $BA=A$ then  $A^2+B^2$ equals ?
(a) $2AB$
(b) $2BA$
(c) $A+B$
(d) $AB$

I tried 
$(A+B)^2=A^2+B^2+AB+BA$
or,$A^2+B^2=(A+B)^2-AB-BA$
$=(A+B)^2-A-B$
$
=(A+B)^2-(A+B)=(A+B)(A+B-1)$
How to reach the answer from here?

First, here is how you can figure out the answer by process of elimination. We can see that if $A$ and $B$ are both identity, then the condition is satisfied, and $A^2 + B^2 = 2I$ in that case. This rules out option (d). Next, note that $A^2 + B^2$ is symmetric in $A$ and $B$, so if (a) were correct, then by symmetry (b) must be correct also. So that leaves (c).
Now, this doesn't establish that (c) is actually correct. To solve the problem properly, note that
$$A = BA = (AB)A = A(BA) = A^2$$,
and similarly $B = B^2$. Thus, $A^2 + B^2 = A + B$.
