Consider the ODE $$f''(x)+bf'(x)+cf(x)=0.$$
So, we are looking for solution of the form $f(x)=e^{\lambda x}$. If we replace this in the ODE, we get $$\lambda ^2+b\lambda +c=0.$$ Suppose this equation has a double root, i.e. $\lambda ^2+b\lambda +c=(\lambda -r)^2.$
Now, we know that solution are of the form $$f(x)=(A+Bx)e^{rx}.$$
How did we have the idea to consider $xe^x$ ? (because in the case where $\Delta =b^2-4c\neq 0$, i.e. $\lambda ^2+b\lambda +x=(\lambda -r_1)(\lambda -r_2)$, then solution are naturally of the form $$Ae^{r_1x}+Be^{r_2x},$$ where $r_i$ are real or complex depending on the context). So, indeed, if it has a double root, then $$Ae^{rx}+Be^{rx}=De^{rx},$$ and since the set of solution is a vector space of dimension $2$, then we must have an other linearly independent solution. So, how did we think to $xe^{rx}$ ? This comes a bit from nowhere for me. Any idea ?