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$?

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$.