Derivation of variation of parameters
Abel's theorem states that the solution vectors $$ \v Y_1(x) = \pmat{y_1(x) \\ y_1'(x)}, \quad \v Y_2(x) = \pmat{y_2(x) \\ y_2'(x)} $$ are linearly independent at any $x$, so $\v Y_1$ and $\v Y_2$ form a basis in the phase space.
We can write the solution vector of a particular integral $y_p$ as a linear combination of them, $$ \v Y_p(x) = u(x) \v Y_1(x) + v(x) \v Y_2(x). $$ Writing in components, $$ \begin{cases} y_p &= uy_1 + vy_2, \\ y_p' &= uy_1' + vy_2'. \end{cases} $$
We can relate $u$ and $v$ by substituting the derivative of the first equation into the second, $$ {\color{yellow}uy_1'} + u'y_1 + {\color{yellow}vy_2'} + v'y_2 = y_p' = \color{yellow}uy_1' + vy_2' $$ yielding $$ u'y_1 + v'y_2 = 0. \tag{1}$$
Also using the fact that $y_p$ is a solution to the ODE, $$\begin{align*} f(x) &= y_p'' + py_p' + qy_p \\ &= (uy_1'' + u'y_1' + vy_2'' + v'y_2') + (puy_1' + pvy_2') + quy_1 + qvy_2 \\ &= u\underbrace{(y_1'' + py_1' + qy_1)}_0 + v\underbrace{(y_2'' + py_2' + qy_2)}_0 + u'y_1' + v'y_2' \end{align*}$$ so $$ u'y_1' + v'y_2' = f(x). \tag{2} $$
Combining $(1)$ and $(2)$, we can write it in matrix form $$\begin{align*} \pmat{y_1 & y_2 \\ y_1' & y_2'}\pmat{u'\\v'} &= \pmat{0 \\ f} \\ \pmat{u'\\ v'} &= \frac1W \pmat{y_2' & -y_2 \\ -y_1' & y_1}\pmat{0\\ f} \\ &= \pmat{-y_2f/W \\ y_1f/W}. \end{align*}$$ Therefore $$\begin{align*} y_p(x) &= y_2(x)v(x) + y_1(x)u(x) \\ &= y_2(x)\int^x\frac{y_1(\xi)f(\xi)}{W(\xi)}\,d\xi - y_1(x) \int^x \frac{y_2(\xi)f(\xi)}{W(\xi)}\,d\xi \end{align*}$$ where the lower bound is irrelevant as it just adds complimentary functions onto the particular solution.