Let $M_n(m)$ be the set of _all_ $n\times n$ matrices over $\mathbb{Z}/m\mathbb{Z}$, and let $$Z_n(m)=\\{A\in M_n(m) : \det A=0\\}.$$ Chinese remainder theorem says that, for $m_1,m_2$ coprime, the map $$A\mapsto(A\bmod m_1,A\bmod m_2)$$ is a bijection between $M_n(m_1 m_2)$ and $M_n(m_1)\times M_n(m_2)$, and also between $Z_n(m_1 m_2)$ and $Z_n(m_1)\times Z_n(m_2)$. From the link given in the comment above, for prime $p$ we have $$F(n,p):=\\#(M_n(p)\setminus Z_n(p))=\prod_{k=0}^{n-1}(p^n-p^k).$$ Thus the answer is $(pq)^{n^2}-\big(p^{n^2}-F(n,p)\big)\big(q^{n^2}-F(n,q)\big)$ for $n=7, p=2, q=5$.