Since, $AB = A \,\,\,...(i)$
$\Rightarrow (AB) A = A \cdot A = A^2$
$\Rightarrow A(BA) = A^2$
[By associativity of matrix multiplication]
$\Rightarrow AB = A^2 \,\,[\because BA = B]$
$\Rightarrow A = A^2 \,\,$[From E$(i)$]
Since, $BA = B \,\,\,...(ii)$
$\Rightarrow (BA) B = B \cdot B = B^2$
$ B(AB) = B^2$
(By associativity of matrix multiplication]
$\Rightarrow BA = B^2 \,\,[\because AB = A]$
$\Rightarrow B = B^2 \,\,$ [From E $(ii)$]
Thus, $AA$ is equal to $A$ and $BB$ is equal to $B$.
Hence, $A$ and $B$ are idempotent.