While this is a good book, your question precisely touches on a serious issue: while in equation (2.5) their $\phi$ satisfies
$$\phi(\mathbf{x}) = \phi(\mathbf{x},t),$$
in equation (2.25) their $\hat{\phi}$ satisfies
$$\hat{\phi}(\mathbf{x}) \neq \hat{\phi}(\mathbf{x},t)$$
i.e. the $t$-dependence completely disappears without a real explanation.
Below equation (2.20) they explicitly say they are setting up the Schrodinger picture, where operators are explicitly time-independent. This is why they are emphasizing the $\mathbf{x}$ dependence and not a $t$ dependence also.
This might lead one to think the $t$ dependence was never there in $\mathcal{L}$ and $\mathcal{H}$, but it's there in the Klein-Gordon equation and in fact they couldn't derive Klein-Gordon or even use the action formalism without that $t$ dependence, so explaining how that $t$-dependence goes away is actually important to understand.
They hide the transition from $t$ dependence (before (2.25)) to non-$t$-dependence (from (2.25) on) both in the notation they use and the 1D Harmonic Oscillator analogy they give after equation (2.20) to argue what the right time-independent fields should look like, obviously the reason for this approach is to emphasize the similarity with Harmonic Oscillators.
That this is all correct is thus again hidden in what they do in section (2.4) showing the Heisenberg picture comes from the time-independent guess they made for what the time-independent Schrodinger picture operator (2.25) should be, even though the Klein-Gordon equation, it's solutions and the action they were using to set it up were all explicitly time-dependent.
So, assuming that the $t$ is still there in section 2.2, it explains why the section before equation (2.4) used the $x = (t,\mathbf{x})$ notation, and are just emphasizing the $\mathbf{x}$ dependence because they want to try to interpret the classical fields as time-independent Schrodinger picture operators (as said below eq. (2.20)).
In (2.25) to (2.28) it's only because they argued by analogy with the 1D Harmonic Oscillator that they can write the general mode expansion of the fields $\hat{\phi}$ (and so $\pi$) as time-independent. But if one wants to avoid guesses, we should be able to get to (2.25) with the $t$ dependence still there, so the $a_{\mathbf{p}}$'s are really $a_{\mathbf{p}}(t)$'s. There is a very clear jump of logic hidden in this analogy, which is good but can be very confusing.
So if the $\phi$'s depend on $t$, and so $x = (t,\mathbf{x})$, the only way this procedure can be consistent is if the time dependence 'separates' off from the full expansion of the quantum or classical field. If you look between (2.20) and (2.21) they use the time-dependence of the fields on $t$ in setting up their 1D Harmonic Oscillator analogy so they are not being consistent with how they deal with $t$.
So really, all of this is actually the Heisenberg picture derivation until the guessing starts coming in. Compare to ([2], Ch. 3) which does a similar derivation (with no analogies) in the Heisenberg picture.
So how would the P&S description go if they didn't guess?
First off, we'd still have to get (2.25) next. We can just write down the general mode expansion of $\hat{\phi}$ in (2.25) as the general solution of the Klein-Gordon equation, but with the time-dependence included, i.e. $\hat{\phi}(x) = \hat{\phi}(\mathbf{x},t)$. See reference [3] below, equations (43.3 - 43.11), if you want to see this spelled out in a lot more detail.
We now need to get rid of the $t$-dependence in (2.25) to get the Schrodinger picture perspective. If you now look at (2.32), the $[\hat{H},\hat{a}_{\mathbf{p}}] = ...$ type relations, or rather their form in terms of exponentials in (2.46), these are the key relations which let us do this. So in this sense it would be good to have done (2.44) to (2.49) next.
Then, using (2.32)/(2.46) it is a simple exercise to re-write the (now time-dependent) $\hat{\phi}(\mathbf{x},t)$ in (2.25) as (2.43) which is
$$\hat{\phi}(\mathbf{x},t) = e^{\hat{H}t} \hat{\phi}(\mathbf{x})e^{-i \hat{H} t}$$
This, finally, justifies working with the time-independent Schrodinger operators
$$\hat{\phi}(\mathbf{x}).$$
Obviously a Schrodinger picture should exist, so they can just assume it exists but they then have to ignore the fact they assumed time-dependence in the Klein-Gordon equation and found it in it's solutions, then just assume they result in a Schrodinger picture operator when quantized, and then just skip the details of the transition by arguing from analogy (as they do after (2.20)) for what the time-independent operators should look like. The justification seems to be that it all works out in section 2.4 since starting from their analogy-based (2.25) you get from this (in (2.43)) a Heisenberg picture which gives back the Klein-Gordon equation.
Without arguing by analogy, only now can we really say the (what they said you're supposed to assume are time-independent, despite using time-dependence again right below them) commutation relations in (2.20) are consistent. We really should have specified they were Heisenberg picture commutators at a fixed time in (2.20) (compare to [2] eq'n (3.28)). In fact they put "equal-time" in scare-quotes below it after simply stating they were time-independent operators (even though they use time-dependence right below this and say above 2.25 they are talking about the classical Klein-Gordon Hamiltonian which was derived using time-dependent fields, there's simply a big jump there).
So the way to read this is: Section 2.2 has time-dependence (despite the notation) so is the Heisenberg picture; Section 2.3 has no time-dependence (though they use crucially time-dependence in (2.21) justifying their analogy letting them avoid the details of how time dependence is gotten rid of) and they use analogies to argue what the Schrodinger picture should look like; Section 2.4 shows the guess they made in Section 2.3 gives the correct properties one would expect from the Heisenberg-Schrodinger picture transition. They could have just derived the Schrodinger picture by having kept going with the Heisenberg picture perspective and put the guessing after to show it gave the answer one would expect, the price one pays is potentially putting in the kind of derivation given in [3] and the benefit is supposed to be exploiting one's familiarity with Harmonic Oscillators.
References:
- Peskin and Schroeder, "Quantum Field Theory", 1st Ed.
- Srednicki, "Quantum Field Theory", 1st Ed.
- Woit, "Quantum Theory, Groups and Representations".