Let $E/\mathbb{Q}$ be an elliptic curve. The $L$-function of $E$ is defined to be the Euler product $$ L_E(s) = \prod_{\text{ bad }p} (1 - a_p p^{-s})^{-1} \prod_{\text{ good }p} (1 - a_p p^{-s} + p^{1-2s})^{-1}, $$ where $a_p = p + 1 - \#E(\mathbb{F}_p)$ if $p$ is a good prime and $a_p \in \{ 0, \pm 1\}$ if $p$ is a bad prime. A lot of textbooks I've read then says that then $L_E(s)$ can be written as a Dirichlet series $$ L_E(s) = \sum_{n=1}^\infty a_n n^{-s}, $$ by using unique factorization in $\mathbb{Z}$. The problem is, I don't see how to get there.
I understand that there are only finitely bad primes, so we can just focus on the good primes. The good primes factor in $L_E(s)$ can be expanded using the standard power series identity $1/(1-z) = 1 + z + z^2 + \cdots$, so we get \begin{align} \frac{1}{1 - (a_p p^{-s} - p^{1-2s})} = \sum_{i=0}^\infty (a_p p^{-s} - p^{1-2s})^i. \end{align} But then I don't know how to proceed anymore. I've tried binomial expansion but that doesn't seem to get me nearer to the solution. Any hints in expanding the Euler product of the $L$-function? I apologize if this is a stupid question.
For each individual $p$, you may view $p^{-s}$ as a formal variable, say $T$.
Thus e.g. for a good $p$, the Euler factor is $(1 - a_p T + pT^2)^{-1}$.
This can then be expanded as a formal power series in $T$. We have: $$(1 - a_p T + pT^2)^{-1} = 1 + a_p T + (a_p^2 - p)T^2 + (a_p^3 - 2pa_p)T^3 + \dots$$
Now for every $p$ you get a series $\sum_r a_{p^r} p^{-rs}$ and the product gives you a Dirichlet series $\sum_n a_n n^{-s}$.