I am trying to count the total possible number of group homomorphisms from $\Bbb Z_p$ to $\operatorname{GL}_2(\Bbb Z_q)$, where $p<q$ are primes and $\Bbb Z_p$ denotes the additive group modulo $p$.
To start with, note that $\operatorname{GL}_2(\Bbb Z_q)$ has $$(q^2-1)(q^2-q) = q(q-1)^2(q+1)$$ elements, and counting $$n=\text{# of homomorphisms }\phi: \Bbb Z_p\to\operatorname{GL}_2(\Bbb Z_q)$$ is the same as counting$$n=\text{# of elements in }\operatorname{GL}_2(\Bbb Z_q)\text{ that could be the image of }1.$$
The map $\phi$ is uniquely determined by $\phi(1)$ and is well-defined on $\Bbb Z_p$ iff $\phi(1)^p=\operatorname{id}_2$, the identity $2\times 2$ matrix. In other words, $$n=1+ \text{ # of elements in }\operatorname{GL}_2(\Bbb Z_q)\text{ of order }p.$$
If some $2\times 2$ matrix $A$ has $A^p = \operatorname{id}_2$, then the degree of the minimal polynomial $p_A$ of $A$ divides the degree of characteristic polynomial $q_A$ of $A$, which in this case $\deg p_A \mid \deg q_A = 2$. Moreover, $p_A$ divides $x^p - 1 = (x-1)(x^{p-1}+\dots+x+1)$.