To show that $\operatorname{Rank}(\mathbf{A}-\mathbf{I})=\operatorname{Nullity}(\mathbf{A})$ Problem is:

Let $\mathbf{A}$ be $n\times n$ matrix with real entries such that $\mathbf{A}^{2} = \mathbf{A}$. If $\mathbf{I}$ denotes the identity matrix, then how do I prove the result: $$\operatorname{Rank}(\mathbf{A}-\mathbf{I})=\operatorname{Nullity}(\mathbf{A})$$ 

I have trivially shown by taking $\mathbf{A}=\mathbf{I}$, but in general I do not know how to prove this, thanks for help.
 A: here is what i think is a shorter proof of $$ A^2 = A \implies ker(A) = image(A-I)  $$ 
proof: write $A^2 = A$ as $A(A-I) = 0$ this means that every column of $A-I$ is in $ker(A),$ therefore $image(A-I) \subset ker(A).$ 
to show the other direction, pick $x \in ker(A),$ so that $Ax = 0.$ 
then $x = x - Ax = (I-A)x$ that is $x \in image(A-I)$ that proves $\ker(A) \subset image(A-I)$
now the result $$rank(A-I) = dim(ker(A)) = nullity(A)$$  follows.
p.s.: this seems too good to be true. i hope i did not make any logical errors.
A: Hint:
$$
\mathbf{A}^{2} = \mathbf{A}
\quad
\Leftrightarrow
\quad
\mathbf{A}^{2} - \mathbf{A} = \mathbf{0}_{n\times n}
\quad
\Leftrightarrow
\quad
\mathbf{A} \left(\mathbf{A}-\mathbf{I}\right) = \mathbf{0}_{n\times n}.
$$
Let $\mathbf{B} = (\mathbf{A} - \mathbf{I})$.
The above implies that every  vector in the range of $\mathbf{B}$ lies in the nullspace of $\mathbf{A}$. Can you take it from there?
Edit: I am expanding the answer because it seems we need to clarify a few things. 
Why is it that the range of $\mathbf{B}$ lies in the nullspace of $\mathbf{A}$?
Let $\mathbf{w}$ be any vector in the range of $\mathbf{B}$, $\mathcal{R}(\mathbf{B})$. This means that we can write $\mathbf{w}$ as a linear combination of the columns of $\mathbf{B}$, i.e., there exists a $\mathbf{c}$ such that $\mathbf{w}=\mathbf{B}\mathbf{c}$. But,
$$
\mathbf{A}\mathbf{w} 
=\mathbf{A}\mathbf{B}\mathbf{c}
= \mathbf{0}_{n\times n} \mathbf{c}
= \mathbf{0},
$$
which implies that $\mathbf{w}$ belongs to the nullspace of $\mathbf{A}$, $\mathcal{N}(\mathbf{A})$.
Hence, we have shown that
$$
\mathbf{w} \in \mathcal{R}(\mathbf{B})
\quad
\Rightarrow
\quad
\mathbf{w} \in \mathcal{N}(\mathbf{A}),
$$
or equivalently,
$$
\mathcal{R}(\mathbf{B}) \subseteq \mathcal{N}(\mathbf{A}).
$$
The above implies that
$$
\text{nullity}(\mathbf{A}) \ge \text{rank}(\mathbf{B})=\text{rank}(\mathbf{A}-\mathbf{I}).
$$
But we are not quite done yet, since we want to show that the two sides are actually equal. 
I am assuming that you should be familiar with the Rank-Nullity Theorem. How can you use that to show the other side of the inequality.
Edit 2: (This is the point where hints start looking a lot like an answer!)
The  Rank-Nullity Theorem theorem says that
$$
 n = \text{rank}(\mathbf{A}) + \text{nullity}(\mathbf{A})
\quad
\Rightarrow
\quad
\text{nullity}(\mathbf{A}) = n - \text{rank}(\mathbf{A}).
$$
What can you say about $\text{rank}(\mathbf{A} - \mathbf{I})$ with respect to $\text{rank}(\mathbf{A})$? How can you get it into the picture? (Remember! we are trying to show that $\text{nullity}(\mathbf{A}) \le \text{rank}(\mathbf{A} - \mathbf{I})$ because we have already shown the reverse inequality.)
Edit 3:
We have already shown that 
$\text{nullity}(\mathbf{A}) \ge \text{rank}(\mathbf{A}-\mathbf{I})$.
To show that the relation holds with equality, it suffices to show that 
$$
\text{nullity}(\mathbf{A}) \le \text{rank}(\mathbf{A}-\mathbf{I}).
$$
We have already seen that
$$
\text{nullity}(\mathbf{A}) = n - \text{rank}(\mathbf{A}).
$$
Hence, to show the desired result, it suffices to show that
$$
n - \text{rank}(\mathbf{A}) \le \text{rank}(\mathbf{A}−\mathbf{I}).
$$
One way to argue about this, possibly not the best, is the following.
Let $\mathbf{B} = \mathbf{A} - \mathbf{I}$. By the rank-nullity theorem, we know that
$$
\text{rank}(\mathbf{B})
+
\text{nullity}(\mathbf{B}) = n.
$$
Now, the nullspace of $\mathbf{B}$, $\mathcal{N}(\mathbf{B})$, consists of all vectors $\mathbf{w}$ such that $\mathbf{B}\mathbf{w}=\mathbf{0}$, or equivalently:
$$
\mathbf{w} \in \mathcal{N}(\mathbf{B})
\quad
\Leftrightarrow
\quad
(\mathbf{A}-\mathbf{I})\mathbf{w} = \mathbf{0}
\quad
\Leftrightarrow
\quad
\mathbf{A}\mathbf{w} = \mathbf{w}.
$$
These vectors $\mathbf{w}$ are clearly just a subset of the range of $\mathbf{A}$.
In other words,
$$
\mathbf{w} \in \mathcal{N}(\mathbf{B})
\quad
\Rightarrow
\quad
\mathcal{R}(\mathbf{A}),
$$
and in turn,
$
\mathbf{w} \in \mathcal{N}(\mathbf{B})
\subseteq
\mathcal{R}(\mathbf{A}).
$
We conclude that $\text{nullity}(\mathbf{B}) \le \text{rank}(\mathbf{A})$ and finally,
$$
\text{rank}(\mathbf{B}) 
= n-\text{nullity}(\mathbf{B})
\ge n-\text{rank}(\mathbf{A}),
$$
which is the desired inequality
$$
\text{rank}(\mathbf{A}-\mathbf{I}) \ge n-\text{rank}(\mathbf{A}).
$$
