This question already has an answer here:
I am asked to count the total number of matrices in $GL_2(F_p)$, where $F$ is a field and $p$ is a prime number, denoting the number of its elements, by first computing the total number of matrices over $F_p$, and then subtracting the total number of non-invertible matrices, which is the total number of matrices whose one row is a multiple of the other.
Clearly there are $p^4$ total matrices over $F_p$. Now, let us consider non-invertible. There are two general cases, either the first row is [0 0] or it is not. If it is, then for the second row [a b], there are $p$ possibilities for $a$ and $p$ possibilities for $b$. Hence, a total of $p^2$ possibilities under this case.
Now, if the first row [x y] is not zero, then either $x \neq 0$, $y \neq 0$, or $x$ and $x$ are not equal to zero. Note, our second row is of the form [kx ky], so that it is a multiple of the first. If $x \neq 0$, then there are $(p-1)$ possibilities for $x$, $p$ for $y$, and $p$ for $k$. Hence, a total of $(p-1) \cdot p \cdot p = p^3 - p^2$. We get the same number of the $y \neq 0$ case. Finally, if $x \neq 0$ and $y \neq 0$, then $(p-1)$ choices for $x$ and $y$, and $p$ choices for $k$, totaling to $(p-1)(p-1)p = p^3 - 2p^2 + p$.
However, this does sum to $p^3 + p^2 + p$, which is the answer. What did I do wrong? I have been working on this all day; combinatorics comes very difficult for me.