My argument is as follows:
Let $R$ be a commutative ring with unity, $I$ an ideal of $R$. If $(R/I)^n\cong (R/I)^m$ as $R$-modules, then it follows that they are isomorphic as $R/I$-modules because the isomorphism factors through the quotient. We observe that these are both free $R/I$-modules with bases $${\mathfrak{B}_1=\{\delta_{1j}+I, \delta_{2j}+I, \dots, \delta_{nj}+I\} \;\;\text{ and }\;\; \mathfrak{B}_2=\{\delta_{1j}+I, \delta_{2j}+I, \dots, \delta_{mj}+I\}}$$ respectively. Then the isomorphism between $(R/I)^n \cong (R/I)^m$ as $R$-modules induces an isomorphism of these free modules, meaning there is a bijection between the elements of $\mathfrak{B}_1$ and $\mathfrak{B}_2$. It follows then that $n=m$.