In Peskin and Schroeder, they quantize the Klein-Gordon field in the following way. They write the Fourier transform of $\phi(x,t)$ $$ \phi(x,t)=\int \frac{d^3 p}{(2\pi)^3}e^{ipx}\phi(p,t) $$ after that they say that the Klein-Gordon equation reduces to $$ \left(\frac{\partial^2}{\partial t^2}+\omega_p\right)\phi(p,t)=0 $$ We have an harmonic oscillator for each $p$. They recall how to quantize an harmonic oscillator saying that for the following Hamiltonian $$ H=\frac{1}{2}p^2+\frac{1}{2}\omega^2 \phi^2 $$ we have $$ \phi=\frac{1}{\sqrt{2\omega}}(a+a^{\dagger}) $$ and that we have therefore $$ \phi(x)=\int \frac{d^3 p}{(2\pi)^3}\frac{1}{\sqrt{2\omega_p}}(a_p e^{ipx}+a_p ^\dagger e^{-ipx})\, . $$
What I don't understand is that we should have $$ \phi(p)=\frac{1}{\sqrt{2\omega_p}}(a_p + a_p ^\dagger) $$ and then remplacing in the Fourier expansion $$ \phi(x)=\int \frac{d^3 p}{(2\pi)^3}\frac{1}{\sqrt{2\omega_p}}(a_p+a_p ^\dagger)e^{ipx} $$ by this method if we are doing an analogy with a single harmonic oscillator. I understand that this can’t be correct but I don't see why, with this particular method we have this result. I understand that by solving the Klein-Gordon equation you get both types of plane wave but I’m having trouble understanding this particular method of quantizing the field.