$\begin{align*}\dfrac{\sin(f+g)+\sin(f-g)}{\cos(f+g) + \cos(f-g)} & = \dfrac{\sin f \cos g + \cancel{\sin g \cos f} + \sin f \cos g + \cancel{- \sin g \cos f}}{\cos f \cos g + \cancel{-\sin f \sin g} + \cos f \cos g + \cancel{\sin f \sin g}} \\ & = \dfrac{\cancel{2}\sin f \cancel{\cos g}}{\cancel{2}\cos f \cancel{\cos g}} \\ & = \tan f\end{align*}$
Because we cancelled $\cos g$ from top and bottom, we need $\cos g \neq 0$. Because $\tan f$ is not defined when $\cos f = 0$, there is no need to specifically identify that as a condition.
You just missed the last steps where you cancel the 2's and cancel the $\cos g$ from top and bottom.