If you want a formal way of looking at this, we can use the methods in The Integrator's answer, but justify them. Often, the question of necessity is skipped in explaining this method of solving, i.e. why a solution to the equation must necessarily be of this form. One way to fill in this hole is using the existence-uniqueness theorem, but there is a more direct way of doing it.
Consider (for inspiration), the characteristic polynomial:
$$r^2 - 1 = (r - 1)(r + 1).$$
From the $r + 1$ factor, I suggest letting $y(x) = f'(x) + f(x)$ (we could also set $y(x) = f'(x) - f(x)$ and get good results). Then,
$$f''(x) - f(x) = f''(x) + f'(x) - f'(x) - f(x) = y' - y = 0.$$
We can now solve $y' - y = 0$, using integrating factors. Multiply through by $e^{-x}$, and we get
$$e^{-x} y' - e^{-x} y = (e^{-x} y)' = 0.$$
Therefore,
$$e^{-x}y = C \implies y = C e^x$$
for some constant $C$.
Now, we have
$$f'(x) + f(x) = y = Ce^x.$$
Using an integrating factor of $e^x$, we get
$$(e^x f(x))' = e^x f'(x) + e^x f(x) = Ce^{2x}$$
Integrating both sides,
$$e^x f(x) = \frac{C}{2} e^{2x} + D \implies f(x) = \frac{C}{2} e^x + De^{-x}.$$
That is, every solution must satisfy the expected form.