Let $C=I-A$. Then $$C^2 =(I-A)^2=I-2A+A^2=I-A=C\ .$$
So $C$ is a projection onto its image. An element $v$ in the vector space $V=\Bbb R^n$ has then the unique decomposition $v=(I-A)v+Av$ as a sum of an element in the kernel of $A$, $(I-A)v$, and an element in the image of $A$, $Av$. The kernel of $A$ is the image of $C$ and conversely. So we have to show that if $B-C$ is invertible, the $B,C$ have complementary dimensions for the kernels. Or for the images, whatever we prefer.
If the kernels have sum of dimensions $>n$, we find a non-zero $v$ in the intersection of these kernels, so $(B-C)v=Bv-Cv=0-0=0$, contradiction.
If the kernels have sum of dimension $<n$, then the images exceed, we find a non-zero $w$ with $w=Bw=Cw$, so $(B-C)w=0$. Contradiction again.