Derivation of integrating factor
The trick is to multiply by a specific integrating factor $\mu(x)$ on both sides: $$ \underbrace{\mu y' + (\mu p)y}_\text{looks like product rule!} = \mu f. $$ Therefore we let $$ \mu' = \mu p. $$ Solving, $$\begin{align*} \int\frac{\mu'}{\mu}\,dx &= \int p(x)\,dx \\ \ln \mu &= \int p(x)\,dx. \end{align*}$$ (The integration constant does not matter as it contributes to an irrelevant constant multiple in $\mu$.)
So now we can write $$\begin{align*} \mu y' + \mu' y = (\mu y)' &= \mu f \\ y(x) &= \frac{1}{\mu(x)}\int^x \mu(u) f(u)\,du \end{align*}$$