I believe you miscalculated the first time. $|M_3(\mathbb Z_2)|=2^{3^2}=2^9=512$. Now, let's calculate the order of $|GL_3(\mathbb Z_2)|$. How many choices do we have for the first column? For the matrix to be invertible, it can be anything except all zeroes, so we have $2^3-1$ choices. For the second column, we need to pick anything that is not a multiple of the first column. Since we are in $\mathbb Z_2$, there are two possible multiples, which would mean we have $2^3-2$ choices for the second column. Similarly, the last column has $2^3-2^2$ choices as we need to avoid picking anything that is a multiple of the first two columns, so the order of the group is
$$(2^3-1)(2^3-2)(2^3-2^2)=168$$
In general, building off of this idea, we have the order of $GL_m(\mathbb Z_q)$ as
$$\prod_{k=0}^{m-1}(q^m-q^k).$$