The proof requires an application of Rolle's theorem to
$$h(x) = f(x) - \frac{f(b)}{g(b)}g(x).$$
Since $h(b) = 0$, this requires $h(a) = 0$ for all $b >a$. This is satisfied if $f(a) = g(a) = 0$ either outright or by continuous extension using $f(x),g(x) \to 0$ as $x \to a+$.