Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 1.4 Exercise 1.4.7
Let $p$ be a prime. Prove that the order of $GL_2(\mathbb{F}_p)$ is $p^4 – p^3 – p^2 + p$. [Hint: subtract the number of noninvertible $2 \times 2$ matrices over $\mathbb{F}_p$ from the total number of such matrices. You may use the fact that a $2 \times 2$ matrix is not invertible if and only if one row is a multiple of the other.]
Solution: The total number of $2 \times 2$ matrices over $\mathbb{F_p}$ is $p^4$.
Now let’s try to construct all possible noninvertible $2 \times 2$ matrices. The first row of a noninvertible matrix is either $[0,0]$ or not. If it is, since every element of $\mathbb{F}_p$ is a multiple of zero, then there are $p^2$ possible ways to place elements from $\mathbb{F}_p$ in the second row. Now suppose the first row is not zero; then it is one of $p^2 – 1$ other possibilities. For each choice, the matrix will be noninvertible precisely when the second row is one of the $p$ multiples of the first, for a total of $p(p^2 – 1)$ possibilities. This gives a total of $p^3 + p^2 – p$ noninvertible matrices, all distinct. Moreover, every noninvertible matrix can be constructed in this way. So the total number of invertible $2 \times 2$ matrices over $\mathbb{F}_p$ is $p^4 – p^3 – p^2 + p$.