[proofplan]
We use the character orthogonality relation on the finite abelian group $(\mathbb{Z}/q\mathbb{Z})^\times$ to build an indicator for the residue class $a \pmod q$ among integers coprime to $q$. After substituting $n=p$ for primes not dividing $q$, the indicator selects exactly those primes congruent to $a$ modulo $q$. The interchange of the character sum with the prime sum is justified because the character sum is finite and the prime series is absolutely bounded by $\sum_{n=1}^\infty n^{-s}$ for $s>1$.
[/proofplan]
[step:Build the residue-class indicator from Dirichlet characters]
Let $G := (\mathbb{Z}/q\mathbb{Z})^\times$ be the multiplicative group of invertible residue classes modulo $q$, and let $\widehat{G}$ denote its character group. For a Dirichlet character $\chi \bmod q$, we regard $\chi$ as the extension to $\mathbb{Z}$ of a character on $G$, with $\chi(n)=0$ when $\gcd(n,q)>1$.
For every integer $n \in \mathbb{Z}$ with $\gcd(n,q)=1$, the residue classes $[a]_q,[n]_q \in G$ are defined. The character orthogonality relation on $G$ gives
\begin{align*}
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(n)
&=
\frac{1}{|G|}
\sum_{\chi \in \widehat{G}}
\chi([n]_q[a]_q^{-1}) \\
&=
\begin{cases}
1, & [n]_q=[a]_q,\\
0, & [n]_q\neq [a]_q.
\end{cases}
\end{align*}
Since $[n]_q=[a]_q$ is equivalent to $n \equiv a \pmod q$, this becomes
\begin{align*}
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(n)
=
\begin{cases}
1, & n\equiv a\pmod q,\\
0, & n\not\equiv a\pmod q,
\end{cases}
\end{align*}
for every $n$ coprime to $q$.
[guided]
The purpose of the character sum is to manufacture an indicator function for one residue class. Since $\gcd(a,q)=1$, the class $[a]_q$ belongs to the unit group
$G := (\mathbb{Z}/q\mathbb{Z})^\times$. If $\gcd(n,q)=1$, then $[n]_q$ also belongs to $G$.
A Dirichlet character modulo $q$ is a character of $G$ extended to all integers by setting it equal to $0$ on integers not coprime to $q$. Therefore, for $\gcd(n,q)=1$, the values $\chi(a)$ and $\chi(n)$ are values of the corresponding group character on $[a]_q$ and $[n]_q$. Because character values on a finite group lie on the unit circle, $\overline{\chi(a)}=\chi([a]_q)^{-1}=\chi([a]_q^{-1})$. Hence
\begin{align*}
\overline{\chi(a)}\chi(n)
=
\chi([a]_q^{-1})\chi([n]_q)
=
\chi([n]_q[a]_q^{-1}).
\end{align*}
The orthogonality relation for characters of the finite abelian group $G$ says that
\begin{align*}
\frac{1}{|G|}\sum_{\chi \in \widehat{G}}\chi(g)
=
\begin{cases}
1, & g=e_G,\\
0, & g\neq e_G,
\end{cases}
\end{align*}
where $e_G$ is the identity element of $G$. Applying this with $g=[n]_q[a]_q^{-1}$ gives
\begin{align*}
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(n)
=
\begin{cases}
1, & [n]_q[a]_q^{-1}=e_G,\\
0, & [n]_q[a]_q^{-1}\neq e_G.
\end{cases}
\end{align*}
The equality $[n]_q[a]_q^{-1}=e_G$ is equivalent to $[n]_q=[a]_q$, which is exactly $n\equiv a \pmod q$. Thus the character average is precisely the indicator of the residue class $a \pmod q$ among integers coprime to $q$.
[/guided]
[/step]
[step:Apply the indicator identity to primes not dividing $q$]
For every prime $p$ with $p\nmid q$, we have $\gcd(p,q)=1$, so the identity from the previous step applies with $n=p$:
\begin{align*}
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(p)
=
\begin{cases}
1, & p\equiv a\pmod q,\\
0, & p\not\equiv a\pmod q.
\end{cases}
\end{align*}
Multiplying by $p^{-s}$ and summing over all primes $p$ with $p\nmid q$ gives
\begin{align*}
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q}}
\left(
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(p)
\right)p^{-s}
=
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q\\ p\equiv a\pmod q}}p^{-s}.
\end{align*}
Since $\gcd(a,q)=1$, no prime satisfying $p\equiv a\pmod q$ can divide $q$: if $p\mid q$ and $p\equiv a\pmod q$, then $p\mid a$, contradicting $\gcd(a,q)=1$. Therefore
\begin{align*}
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q\\ p\equiv a\pmod q}}p^{-s}
=
\sum_{\substack{p \ \mathrm{prime}\\ p\equiv a\pmod q}}p^{-s}.
\end{align*}
[/step]
[step:Exchange the finite character sum with the prime sum]
For every Dirichlet character $\chi \bmod q$ and every prime $p$, we have $|\chi(p)|\leq 1$. Since $s>1$,
\begin{align*}
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q}}
|\chi(p)p^{-s}|
\leq
\sum_{\substack{p \ \mathrm{prime}}}p^{-s}
\leq
\sum_{n=1}^{\infty}n^{-s}
<\infty.
\end{align*}
Thus each inner prime sum is absolutely convergent. The set of Dirichlet characters modulo $q$ has exactly $\varphi(q)$ elements, so the character sum is finite. Hence we may rearrange the finite sum:
\begin{align*}
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q}}
\left(
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}\chi(p)
\right)p^{-s}
&=
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}
\sum_{\substack{p \ \mathrm{prime}\\ p\nmid q}}
\chi(p)p^{-s}.
\end{align*}
Combining this equality with the identity obtained in the previous step yields
\begin{align*}
\sum_{\substack{p \ \mathrm{prime} \\ p \equiv a \pmod q}} p^{-s}
=
\frac{1}{\varphi(q)}
\sum_{\chi \bmod q}
\overline{\chi(a)}
\sum_{\substack{p \ \mathrm{prime} \\ p \nmid q}}
\chi(p)p^{-s}.
\end{align*}
This is the desired formula.
[/step]