I find this a rather awkward question, from the book "Mathematical Circles" by Fomin, Genkin and Itenberg. The question number is Question number 23 from Chapter 12 ("Invariants"). I was given a hint: use invariants, which I found even more awkward.

There was also a remark : "strange as it may seem, this is an invariants problem". Funny , because I don't know what to expect now!

Suppose $M$ is an $m \times n$ matrix such that all rows and columns of $M$ sum to $1$. Show that $m=n$.

I have no clue how this is a problem on invariants, let alone how to solve this problem. I'll need hints on why this is the case.