It
doesn't. For example, the equation y"= 0 is of that form with n= 2,

,

but its general solution is y(x)= Cx+ D, not an exponential at all.
Also, y"+ y= 0 , with n= 2,

and

has general solution y(x)= C cos(x)+ D sin(x).
You can see that those are solutions by finding the first and second derivatives and plugging them into the equations.
The basic idea is good: by
trying a solution of the form

, you get the "characteristic equation" which will then lead you to find the general solution even if it
isn't exponential. You just need to learn more.
For example, if we put

,

,

into the two equations above, you get

and

. Since

is never 0, those reduce to

and

, respectively.
The first equation gives us z= 0 which tells us

is a solution which is why that constant, D, above, is a solution. Since that is the only root, we must learn other reasons to know that multiplying by x also gives a solution.
The second equation has
no real solutions- its roots are the imaginary numbers i and -i. You need to learn that "complex exponentials" can be written in terms of sine and cosine.
I suspect you will be learning those things shortly. Have fun!