Answer
See below.
Work Step by Step
Let $A$ be an $n\times m$ matrix and $B$ be an $o\times p$ matrix. Then by definition, for AB to be defined, $m=p$ and $n=o$, for BA to be defined, $m=o$ and $n=p$; thus $o=n=m=p$, and thus they are both square matrices. Therefore, we proved what we had to.