Let $\mathbb{F}_p$ be a field with $p$ elements and $\mathbb{M}_n(\mathbb{F}_p)$ is the set of all $n \times n$ matrices over the field $\mathbb{F}_p$.
Now, we know that $|\mathbb{M}_n(\mathbb{F}_p)| = p^{n^2}$. The number of matrix with rank $0$ is $1$, namely the null matrix of order $n$. Number of matrices with rank $n$ is $$\prod_{i=0}^{n-1} (p^n-p^i),$$ namley $GL(n, \mathbb{F}_p)$.
How many elements with rank $r~ (0 \leq r \leq n)$ in $\mathbb{M}_n(\mathbb{F}_p)$?
Note: If we denote the number of elements with rank $i~ (0 \leq i \leq n)$ is $R_i$ in $\mathbb{M}_n(\mathbb{F}_p)$ then $$\sum_{i=0}^{n} R_i= p^{n^2}.$$
One cal build a recursive formula for computing the number of matrices $m\times n$, with coefficient in $\mathbb F_p$, of a given rank $r$. Let $k(m,n,r)$ be such number.
Let $M$ be a matrix of rank $r$ and let $N$ be the matrix $m\times(n-1)$ obtained by deleting the last column $v$ of $M$. Then $N$ has rank either $r$ or $r-1$. If $N$ has rank $r$, then $v$ belongs to the $r$-dimensional space of $\mathbb F_p^m$ generated by the columns of $N$. If $N$ has rank $r-1$, then $v$ belongs to the complement of the $(r-1)$-dimensional space generated by the columns of $N$.
It follows that $$k(m,n,r)=k(m,n-1,r) p^r + k(m,n-1,r-1)(p^m-p^{r-1})$$
The same reasoning apply to the rows. This gives a recursive formula for $k(n,n,r)$ in terms of $k(n-1,n-1,r), k(n-1,n-1,r-1), k(n-1,n-1,r-2)$
I don't know if from that we can deduce an exact formula.