We want to show that
$$
r(A-B) = r(A - AB) + r(AB - B).
$$
By the claim proven below, it suffices to show that $A - AB$, $AB - B$ have trivially intersecting row-spaces and trivially intersecting kernels.
To show that the row-spaces intersect trivially, note that
$$
\operatorname{im}(A - AB)^T = \operatorname{im}((I - B)^TA^T) \subset \operatorname{im}(I-B)^T,\\
\operatorname{im}(AB - B)^T = \operatorname{im}(B^T(I - A^T)) \subset \operatorname{im}(B)^T.\\
$$
However, we have $\operatorname{im}(B)^T \cap \operatorname{im}(I-B)^T = \{0\}$. To see this: if $x$ is in the first space, then $(I - B^T)x = 0$ which means that $B^Tx = x$. If $x$ is in the second space, then $B^Tx = 0$. For both to be true, we must have $x = 0$.
We now show that the kernels intersect trivially. Suppose that $x \in \ker(A-B)$, i.e. $(A-B)x = 0$. This can be rewritten as
$$
(A - B)x = 0 \implies Ax - Bx = 0 \implies Ax = Bx.
$$
It follows that
$$
(A - AB)x = Ax - A(Bx) = Ax - A(Ax) = (Ax - A^2)x = 0.
$$
Similarly,
$$
(AB - B)x = A(Bx) - (Bx) = A(Ax) - (Ax) = (A^2 - A)x = 0.
$$
So, $x \in \ker(A-B)$ implies that $x \in \ker(A - AB)$ and $x \in \ker(AB - B)$. The conclusion follows.
Claim: given $P,Q$ with $\operatorname{im}(P^T)\cap \operatorname{im}(Q^T) = \{0\}$, we have
$$
r(P + Q) = r(P) + r(Q) \iff \ker(P + Q) = \ker(P) \cap \ker(Q).
$$
Proof:
$$
\ker(P + Q) = \ker(P) \cap \ker(Q) \iff\\
\operatorname{im}(P^T + Q^T) = \operatorname{im}(P^T) + \operatorname{im}(Q^T) \iff\\
\dim \operatorname{im}(P^T + Q^T) = \dim \operatorname{im}(P^T) + \dim \operatorname{im}(Q^T) - \dim[\operatorname{im}(P^T) \cap \operatorname{im}(Q^T)]
\iff\\
\dim \operatorname{im}(P^T + Q^T) = \dim \operatorname{im}(P^T) + \dim \operatorname{im}(Q^T) \implies\\
r(P + Q) = r(P) + r(Q).
$$