In the last step. I believe we did
$$\frac{d}{dx} \int_{a}^{x} g = \frac{d}{dx} \lim_{n \to \infty} \int_{a}^{x} f_n' = \lim_{n \to \infty}\frac{d}{dx} \int_{a}^{x} f_n' = \lim_{n \to \infty} f_n'(x)$$
How come we are allow to switch between the limit operator and the differentiation operator?

Since $g$ is continuous, $\int_a^x g(t)\,dt$ is differentiable and its derivative is $g(x)$. (Fundamental theorem of calculus.)
So the last step is just differentiating the equality $$ f(x)-f(a) = \int_a^x g(t)\,dt$$ and using the earlier computation and the assumption that $f_n'$ converges (even uniformly) to $g$.