So this question was recently asked in my exam
If A and B are two square matrices of same order such that $AB=A$ and $BA=B$ then $A^2=?$
Here's what I did
As $$AB=A$$ $$\implies A^{-1}AB=A^{-1}A $$ (pre multiplying by $A^{-1}$) $$ \implies I B = I $$ or $$B=I$$
Here I is identity matrix of same order as A or B.
Similarly we can have from second equation $$A=I$$
Thus it follows $$A^2 = I^2 =I$$
So$$A^2 = I$$
But this was considered wrong and the correct answer was given as A as: $$A^2 = AA$$ $$\implies A^2 = (AB)(A) $$ As $AB=A$ $$\implies A^2 = A(BA) $$ $$\implies A^2 = A B $$ As $BA=B$ $$\implies A^2 = A $$ As $AB=A$
So $$A^2 = A$$
My question:
Why was my response considered wrong when actually both the answers are equivalent as $A= I$ ? Are they correct in saying my answer is wrong?