First, if $q=rs$ with $(r,s)=1$ then $\mathbb{Z}_q^n=\mathbb{Z}_r^n\times\mathbb{Z}_s^n$, and every submodule of $\mathbb{Z}_q^n$ splits uniquely as a direct sum of a submodule of $\mathbb{Z}_r^n$ and a submodule of $\mathbb{Z}_s^n$. Using this, we reduce easily to the case where $q$ is a prime power, say $q=p^m$. Now let $F$ denote the set of free submodules of rank $k$ in $\mathbb{Z}_q^n$, and let $F_0$ be the corresponding set for $\mathbb{Z}_p^n$. By a standard argument which you say you have seen, we have $|F_0|=\pi(n)/(\pi(k)\pi(n-k))$, where $\pi(k)=(p-1)(p^2-1)\dotsb(p^k-1)$. The reduction map $\rho\colon F\to F_0$ is easily seen to be surjective, so you just need to understand $|\rho^{-1}\{A_0\}|$ for $A_0\in F_0$. We can choose $A\in\rho^{-1}\{A_0\}$, and then choose a complement $B$ such that $\mathbb{Z}_q^n=A\times B$. Now $\rho^{-1}\{A_0\}$ is the set of submodules $C\leq A\times B$ that are free of rank $r$ and agree with $A$ mod $p$. For any such $C$, we have projections $A\xleftarrow{f}C\xrightarrow{g}B$, and we see that $f(C)+pA=A$ and $g(C)\leq pB$. As $f(C)+pA=A$ we see that $f$ is surjective, but $|C|=|A|=q^r$ so $f$ is an isomorphism. It follows that $C=\{(a,h(a)):a\in A\}$, where $h=gf^{-1}\in\text{Hom}(A,pB)$. This construction gives a bijection from $\rho^{-1}\{A_0\}$ to $\text{Hom}(A,pB)$, so $|\rho^{-1}\{A_0\}|=p^{(m-1)r(n-r)}$. This is independent of $A_0$, so $$ |F| = p^{(m-1)r(n-r)} \pi(n)/(\pi(r)\pi(n-r)). $$ One can say interesting things about non-free subgroups as well, but I do not have time to write that now.