Find the number of irreducible polynomials in any given degree

For any prime $p$ find the number of monic irreducible polynomials of degree $2$ over $\mathbb Z_p$. Do the same problem for degree $3$. Generalize the above statement to higher degree polynomials as much as you can.

My idea for degree 2: assume that polynomial is reducible, then we can write into this form: $(x-m)(x-n)=0$, expand this, so $x^2-(m+n)x+mn=0$,we can use a matrix to capture all possible value of $(m+n) and$ $mn$, like when $p=3$, $m+n$ matrix is $\begin{matrix} 0&1&2\\ 1&2&0\\ 2&0&1\end{matrix}$, similarly, we can write mn, find the different value, that m,n must be irreducible when we expand (x-m)(x-n)=0.

There are $p^2$ total monic polynomials of degree 2 (where the $p^2$ counts the possible linear and constant term combinations). There are $p+\binom{p}{2}$ monic polynomials of degree 2 that are reducible (where the $p$ counts the ones with a repeated root, and the $\binom{p}{2}$ counts the ones with two distinct roots). So there are $$p^2-\left(p+\binom{p}{2}\right)=\frac{p^2-p}{2}$$ irreducible quadratics. Can you extend this approach to cubics?