[guided]The purpose of Dirichlet characters is to replace the arithmetic condition $n \equiv a \pmod q$ by a finite Fourier expansion on the multiplicative group $(\mathbb{Z}/q\mathbb{Z})^\times$.
Let $\mathcal{X}_q$ be the set of Dirichlet characters modulo $q$, where each character is extended to all integers by the rule $\chi(n)=0$ when $\gcd(n,q)>1$. Let $\chi_0$ be the principal character, so $\chi_0(n)=1$ for $\gcd(n,q)=1$ and $\chi_0(n)=0$ otherwise. Let $A_a := \{m \in \mathbb{N} : m \equiv a \pmod q\}$, and define the indicator function
\begin{align*}
\mathbb{1}_{A_a}: \mathbb{N} &\to \{0,1\} \\
m &\mapsto
\begin{cases}
1, & m \in A_a, \\
0, & m \notin A_a.
\end{cases}
\end{align*}
We write $\mathbb{1}_{\{n \equiv a \pmod q\}}$ for the value $\mathbb{1}_{A_a}(n)$. For each character $\chi \in \mathcal{X}_q$, define
\begin{align*}
\psi_\chi : [1,\infty) &\to \mathbb{C} \\
x &\mapsto \sum_{n \leq x} \Lambda(n)\chi(n).
\end{align*}
We now use the [Orthogonality Relation for Dirichlet Characters](/theorems/TEMP-5):
\begin{align*}
\frac{1}{\varphi(q)}
\sum_{\chi \in \mathcal{X}_q}\overline{\chi(a)}\chi(n)
=
\mathbb{1}_{\{n \equiv a \pmod q\}}.
\end{align*}
The hypothesis $\gcd(a,q)=1$ is used here because $a$ must represent an element of the unit group modulo $q$. If $n \equiv a \pmod q$, then $n$ is also coprime to $q$, and the character sum is the full orthogonality sum at the identity element, hence equals $1$. If $n$ is not congruent to $a$ modulo $q$, then either $n$ is not coprime to $q$, so all characters vanish at $n$, or $n$ is a different unit class, so the orthogonality sum is zero.
Therefore
\begin{align*}
\psi(x;q,a)
&=
\sum_{n \leq x}\Lambda(n)\mathbb{1}_{\{n \equiv a \pmod q\}} \\
&=
\sum_{n \leq x}
\Lambda(n)
\frac{1}{\varphi(q)}
\sum_{\chi \in \mathcal{X}_q}\overline{\chi(a)}\chi(n).
\end{align*}
Because $\mathcal{X}_q$ is finite, the character sum can be interchanged with the finite sum over $n \leq x$, giving
\begin{align*}
\psi(x;q,a)
&=
\frac{1}{\varphi(q)}
\sum_{\chi \in \mathcal{X}_q}
\overline{\chi(a)}
\sum_{n \leq x}\Lambda(n)\chi(n) \\
&=
\frac{1}{\varphi(q)}
\sum_{\chi \in \mathcal{X}_q}
\overline{\chi(a)}\psi_\chi(x).
\end{align*}[/guided]