If $AB=A$ and $BA=B$ then $BA'=A'$ and $AB'=B'$ and hence prove that $A'$ and $B'$ are idempotent. $A'$ and $B'$ denote the transpose of $A$ and $B$, respectively.
Since $A'$ is idempotent, I have to prove $(A')^2 = A'$
$$(A')^2 = (BA')^2 \qquad \text{or} \qquad (B'A')^2$$
I am not able to proceed after this. Please help.
$$A^2 = (A)(A) = (AB)A = A(BA) = AB = A$$ hence $A$ is idempotent. Since $A$ is idempotent, so is $A'$.
An analogous argument shows that $B'$ is idempotent.