Solution (source code)

= Solution

If $M$ is an $r\times s$ <matrix>, the product $M^2=MM$ is defined in ordinary <matrix multiplication> only when $s=r$. Hence the defining equation of an <idempotent matrix> already requires equal row and column counts:
$$
\boxed{M\text{ is square}.}
$$
Equivalently, an <idempotent linear map> is an <endomorphism>, so the same <vector space> is both its domain and codomain.