Because the solution to the equation is known to be of this form! You are, if you like, assuming the form of the answer in advance! This is quite a common procedure in 'solving' differential equations.
If your physical intuition is good, you could identify the [itex]2k\frac{dx}{dt}[/itex] term as due to a resistive force, and guess that there'd be an exponential decay factor in the solution.
Once you've made the substitution [itex]x = e^{-kt} f(t)[/itex], you have a differential equation for [itex]f(t)[/itex], which is just the ordinary shm equation with angular frequency [itex]\omega[/itex] given by [itex]\omega^2 = \omega_0^2 - k^2[/itex], provided that [itex]\omega > k[/itex]. So the solution can be seen immediately, by elementary methods, to be the product of sinusoidally oscillating, and exponential damping, factors. [If [itex]\omega < k[/itex] we have a non-oscillatory fall-off in x with time.]
Making the substitution [itex]x = e^{-kt} f(t)[/itex] involves a bit of drudgery and, imo, one might as well go the whole hog and (if [itex]\omega > k[/itex]) make the substitution [itex]x=Ae^{-kt}sin ({\omega t + \epsilon})[/itex] at the outset. You'll find that this expression does fit, provided that [itex]\omega^2 = \omega_0^2 - k^2[/itex].
If you're happy with complex numbers, and the idea of linear combinations, there is a very slick method which simply requires you to substitute [itex]x=Ae^{-\alpha t}[/itex]. Alpha turns out to be complex if [itex]\omega > k[/itex], and you need to form a linear combinations of two solutions. The mathematics is a bit more advanced than that needed for the substitution [itex]x = e^{-kt} f(t)[/itex] or [itex]x=Ae^{-kt}sin ({\omega t + \epsilon})[/itex].