let A be an nxn matrix st A^2 = A and rank(A) = n.

then the dimension of A should be nxn= n^2 right?

and i was wondering, if the rank(A) =n, then the det A= 1 ( since there will be n leading ones by row operations). then A is invertible.

but should A be invertible, then shouldnt the dimA= n^2 be equal to the dim of the image which in this case is n? there seem to be a contradict