Given :
$AB=A$
$BA=B$
Now $AB=A$-----(1)
Multiplying (1) by $A$, $\rightarrow (AB)A=A^2$
$A(BA)=A^2$(By associative law)
$BA=B$
$\Rightarrow AB=A^2$-------(2)
From eq(1) & eq(2) we get
$A^2=A$
$B^2=B$
$\therefore$ A and B are idempotent matrices.
Hence (B) is the correct answer.