Can someone explain why exactly are we doing the Fourier transform in equation 2.5, what does it mean to choose coordinates in which degrees of freedom decouple?
Lets think of a much simple problem: two masses, connected with springs to the walls and to one another. Such a system satisfies the following set of differential equations
$$\left\{\begin{matrix}m\dfrac{{\rm d}^{2}x_{1}}{{\rm d}t^{2}}&=&-k x_{1}-k\left(x_{1}-x_{2}\right)\\m\dfrac{{\rm d}^{2}x_{2}}{{\rm d}t^{2}}&=&-k x_{2}-k\left(x_{2}-x_{1}\right)\end{matrix}\right.$$
or in a more natural matrix form
$$\dfrac{{\rm d}^{2}\boldsymbol{x}}{{\rm d}t^{2}}=A\boldsymbol{x}$$
with
$$A=\frac{k}{m}\left(\begin{matrix}-2&1\\1&-2\end{matrix}\right)$$
You can clearly see that our matrix is not diagonal. This means that $x_{1}$ affects $x_{2}$ and vice versa. A more natural choice of coordinates is $y_{\pm}=\frac{1}{\sqrt{2}}\left(x_{1}\pm x_{2}\right)$. In this new coordinate system we can write
$$\left\{\begin{matrix}\dfrac{{\rm d}^{2}y_{+}}{{\rm d}t^{2}}&=&-\frac{k}{m} y_{+}\\ \dfrac{{\rm d}^{2}y_{-}}{{\rm d}t^{2}}&=&-\frac{3k}{m}y_{-}\end{matrix}\right.$$
As you can see, this time one equation does not depend upon another. This means that now we have decoupled our degrees of freedom. We have found eigenmodes - two types of combined movements of the two masses that have a dynamic identical to that of a single effective particle. Each with a different frequency. You are probably familiar with these type of questions from early classes on the mechanics of oscillations.
Your problem is not different. Let's, for simplicity, speak of a very similar equation so we can grasp the mathematics more easily
$$\dfrac{\partial^{2}\phi(x,t)}{\partial t^{2}}-\dfrac{\partial^{2}\phi(x,t)}{\partial x^{2}}+m^{2}\phi(x,t)=0$$
You can think of $\phi(x,t)$ as the vector $\left(\dots,\phi(-{\rm d}x,t),\phi(0,t),\phi({\rm d}x,t),\dots\right)^{T}$. Then the spatial second derivative is just a linear operator, or a matrix, since
$$\dfrac{\partial^{2} \phi(x,t)}{\partial x^{2}}\approx\frac{\phi(x+{\rm d}x,t)-2\phi(x,t)+\phi(x-{\rm d}x,t)}{{\rm d}x^{2}}$$
Therefore, returning to your equation, you have
$$\dfrac{\partial^{2} \phi(\boldsymbol{x},t)}{\partial t^{2}}=L\phi(\boldsymbol{x},t)$$
where $L$ is the operator $L\equiv\partial_{j}\partial^{j}-m^{2}$. As I showed above, this $L$ is not diagonal so it couples different $\phi(\boldsymbol{x},t)$ together. To decouple the system, you look at a very common linear combination of such $\phi(\boldsymbol{x},t)$'s - the Fourier Transform
$$\phi(\boldsymbol{p},t)=\int{\rm d}^3x e^{i\boldsymbol{p}\cdot\boldsymbol{x}}\phi(\boldsymbol{x},t)$$
The integral is nothing but the continuum version of the discrete summation $\Sigma$ and $e^{i\boldsymbol{p}\cdot\boldsymbol{x}}$ are the coefficients. As David Tong notes, these linear combinations satisfy a much simpler set of equations. For every $\boldsymbol{p}$ you have
$$\dfrac{\partial^{2}\phi(\boldsymbol{p},t)}{\partial t^{2}}+(p^2+m^2)\phi(\boldsymbol{p},t)=0$$
Now $\phi(\boldsymbol{p}_{1},t)$ does not depend on $\phi(\boldsymbol{p}_{2},t)$, whenever $\boldsymbol{p}_{1}\neq\boldsymbol{p}_{2}$. And that's it! We have found the eigenmodes of this equation, i.e. we have decoupled the system.
From annihilation and creation operators in quantum mechanics, how do we get equation 2.18?
Now let's define $\omega_{\boldsymbol{p}}\equiv\sqrt{p^2+m^2}$ such that
$$\dfrac{\partial^{2}\phi(\boldsymbol{p},t)}{\partial t^{2}}=-\omega_{\boldsymbol{p}}^{2}\phi(\boldsymbol{p},t)$$
That's exactly the equation of an harmonic oscillator, which is quantized in the Heisenberg picture of quantum mechanics in the form
$$\phi(\boldsymbol{p},t)=\frac{1}{\sqrt{2\omega_{\boldsymbol{p}}}}\left[\hat{a}_{\boldsymbol{p}}e^{i(\boldsymbol{p}\cdot\boldsymbol{x}-\omega_{\boldsymbol{p}}t)}+\hat{a}_{\boldsymbol{p}}^{\dagger}e^{-i(\boldsymbol{p}\cdot\boldsymbol{x}-\omega_{\boldsymbol{p}}t)}\right]$$
Then you can return to the coupled basis by an inverse Fourier Transform.