I have known the following exercise for some time. Take $p_1,\ldots,p_n$ idempotents in $M_m(K)$ ($K$ field of characteristic zero). Show that $p:=p_1+\cdots+p_n$ is idempotent if and only if $p_ip_j=0$ for all $i\neq j$. The solution I know essentially uses the fact that the rank of an idempotent is equal to its trace.
I am interested in generalizations of this result. In particular, for what other algebras does this hold? Is there an algebra where this fails? I am asking in particular because I don't know how to find a counterexample. Thanks for your help.