It is known that a projection operator can be written explicitly as follows:
$$\hat{P} = \sum_{k=1}^n \hat{P_k} = \sum_{k=1}^n | k \rangle\langle k|$$
where $\{|k\rangle$, $k= 1,\ldots,n\}$ are the orthonormal basis.
So it is curious to ask if a projection should always be written as the sum of projection operators to the smaller subspaces, which are orthogonal to each other. This is proved as following.
Given two projection operators $\hat{P_1}$ and $\hat{P_2}$, for the sum $\hat{P} = \hat{P_1} + \hat{P_2}$ to be also a projection operator:
$$(\hat{P_1} + \hat{P_2})^2 = \hat{P_1} + \hat{P_2} \\ \Rightarrow \hat{P_1}^2 + \hat{P_2}^2 + \hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1} \\ = \hat{P_1} + \hat{P_2} + \hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1} = \hat{P_1} + \hat{P_2}$$
Therefore we get
$$\hat{P_1}\hat{P_2} + \hat{P_2}\hat{P_1}\tag 1 = 0$$
(1) left-multiplied by $\hat{P_1}$, we get:
$$\hat{P_1}\hat{P_2} + \hat{P_1}\hat{P_2}\hat{P_1} = 0\tag 2$$
(1) right-multiplied by $\hat{P_1}$, we get:
$$\hat{P_1}\hat{P_2}\hat{P_1} + \hat{P_2}\hat{P_1} = 0\tag3$$
(2) - (3) gives:
$$\hat{P_1}\hat{P_2} - \hat{P_2}\hat{P_1} = 0\tag4$$
(1) + (4) eventually gives:
$$\hat{P_1}\hat{P_2} = \hat{P_2}\hat{P_1} = 0\tag5$$
The above proved that equation (5) is the necessary condition for the sum $\hat{P} = \hat{P_1} + \hat{P_2}$ to be also a projection operator. It is straightforward to see that (5) is the sufficient condition, too. So we conclude that:
$$(\hat{P_1} + \hat{P_2})^2 = \hat{P_1} + \hat{P_2} \\ \Longleftrightarrow \hat{P_1}\hat{P_2} = \hat{P_2}\hat{P_1} = 0$$
given two projection operators $\hat{P_1}$ and $\hat{P_2}$.
My question is: what is the general theory/theorem that formally addressed the above question and stated the above result?
The most straightforward generalization of your result is that if $P_1,P_2,\ldots,P_n$ are self-adjoint projections on a Hilbert space, then $P_1+P_2+\cdots+P_n$ is a projection if and only if $P_iP_j=0$ for $i\neq j$. In an abstract formulation of the same result, we would say that the $P_i$s are projections in a C*-algebra (i.e., self-adjoint idempotent elements). It is equivalent because every C*-algebra is *-isomorphic to an algebra of operators on Hilbert space.
A proof of the nontrivial implication is the subject of the question Sums of projections in a C*-algebra.
A special case, where the operators sum to the identity, is the subject of the question Orthogonal projections with $\sum P_i =I$, proving that $i\ne j \Rightarrow P_{j}P_{i}=0$.
And in the nonselfadjoint case, the result need not be true, as seen in the question Non-orthogonal projections summing to 1 in infinite-dimensional space.
However, on a finite dimensional space, the special case where they sum to the identity is still true even without selfadjointness, as seen in the question Multiplication of two projection operator is zero.
As you have shown, by not using selfadjointness or finite-dimensionality, the $n=2$ case depends only on idempotency.