How to show $B^2=B$ when $rank(B) + rank(I_d - B) = d$? I have a question on this specific question from the past entrance examination of a university.
https://www.ism.ac.jp/senkou/kakomon/math_20190820.pdf
Related post: How to calculate eigenvalues of a matrix $A = I_d - a_1a_1^T - a_2a_2^T$
Problem
$≥3$, $_$ is an identity matrix, and $B$ is a d-dimensional square matrix.
Here, how to show $B^2=B$ when $rank(B) + rank(I_d - B) = d$?

Tried
I specifically considered the case of $d = 2$.
In this case, when $rank(B) + rank(I_d - B) = d$, I can find $rank(B) = rank(I_d - B) = 1$
I assume that 


*

*$B = \left[
    \begin{array}{cc}
      a & b \\
      c & d \\
    \end{array}
  \right]
\to \left[
    \begin{array}{cc}
      a & b \\
      0 & d-\frac{c}{a}b \\
    \end{array}
  \right]$

*$I - B = \left[
    \begin{array}{cc}
      1 & 0 \\
      0 & 1 \\
    \end{array}
  \right] - \left[
    \begin{array}{cc}
      a & b \\
      c & d \\
    \end{array}
  \right]
= \left[
    \begin{array}{cc}
      1-a & b \\
      c & 1-d \\
    \end{array}
  \right]
\to \left[
    \begin{array}{cc}
      1-a & b \\
      0 & (1-d)-\frac{c}{(1-a)}b \\
    \end{array}
  \right]$.
From $rank(B) = rank(I-B) = 1$, 


*

*$d - \frac{c}{a}b = 0 \to ad = bc$

*$(1-d)-\frac{c}{(1-a)}b = 0 \to (a+d) = 1$.


And then, 
$
\begin{eqnarray}
B^2 &=& \left[
    \begin{array}{cc}
      a & b \\
      c & d \\
    \end{array}
  \right]\left[
    \begin{array}{cc}
      a & b \\
      c & d \\
    \end{array}
  \right] \\ 
&=& \left[
    \begin{array}{cc}
      a^2 + bc & ab+bd \\
      ac+dc & ad+d^2 \\
    \end{array}
  \right] \\
&=& \left[
    \begin{array}{cc}
      a^2 + ad & ab+bd \\
      ac+dc & ad+d^2 \\
    \end{array}
  \right] \\
&=& \left[
    \begin{array}{cc}
      a(a+d) & b(a+d) \\
      c(a+d) & d(a+d) \\
    \end{array}
  \right] \\ 
&=& \left[
    \begin{array}{cc}
      a & b \\
      c & d \\
    \end{array}
  \right] = B
\end{eqnarray}$
But I don't know how to generalize this.
I guess I can use $A^2 = A$ when $A = I_d - a_1a_1^T - a_2a_2^T$ (link), but I have no idea how to apply it.
 A: $$
\newcommand{\abs}[1]{\left\vert #1 \right\vert}
\newcommand\rme{\mathrm e}
\newcommand\imu{\mathrm i}
\newcommand\diff{\,\mathrm d}
\DeclareMathOperator\sgn{sgn}
\renewcommand \epsilon \varepsilon
\newcommand\trans{^{\mathsf T}}
\newcommand\F {\mathbb F}
\newcommand\Z{\mathbb Z}
\newcommand\R{\Bbb R}
\newcommand \N {\Bbb N}
$$
A proof without the hint.
Suppose we are working on the field $\F$, and we prove this for linear operators $B$ on $V = \F^d$. The assumption suggests
$$
\dim (\ker B) + \dim (\ker (I -B)) = d. 
$$
If $v \in \ker B \cap \ker (I-B)$, then $0=Bv = v - Bv$ hence $v = 2Bv = 0$. Therefore $\ker B + \ker(I-B)$ is a direct sum. Combined with the dimensional equation, 
$$
V = \ker B \oplus \ker (I -B). 
$$
Then $B^2 - B =- B( I -B)$, since for every $v \in V$, $v = w + u$ where $w \in \ker B, u \in \ker (I - B)$, thus
$$
(B^2 - B)v = (I-B)(Bw) + B ((I-B)u) = 0 + 0 = 0, 
$$ 
and hence $B^2 - B = O$ since $v$ is arbitrary. 
A: Let $B'=I_d-B$. Observe that if $v\in\ker B\cap \ker B'$ then $v=Bv+B'v=0$, hence $\dim(\ker B\cap \ker B')=0$. Thus
$$
\dim(\ker B+\ker B')=\dim \ker B+\dim \ker B'=(d-\textrm{rank} B)+(d-\textrm{rank} B')=d.
$$
On the other hand since $B$ and $B'$ commute, every $v\in \ker B+\ker B'$ satisfies $BB'v=0$. Thus $BB'=0$, as desired.
