$xe^{\lambda x}$ is a solution to a simple second order differential equation only if the auxiliary equation has a repeated root, why?

For a differential equation like:

$$a\frac{d^2y}{dx^2}+b\frac{dy}{dx}+cy=0$$

$xe^{\lambda x}$ is a solution if the auxiliary equation: $a\lambda^2+b\lambda+c+0$ has a repeated root. However, it is only a solution in this specific case, why is this so?

Taking $$y=xe^{\lambda x}$$ $$\frac{dy}{dx}=e^{\lambda x} + \lambda xe^{\lambda x}$$ $$\frac{d^2y}{dx^2}=2\lambda e^{\lambda x} + \lambda^{2}xe^{\lambda x}$$

Substituting in the equation $$a\frac{d^2y}{dx^2}+b\frac{dy}{dx}+cy=0$$

As $e^{\lambda x} \neq 0$, We get $$a(\lambda^2x+2\lambda)+b(\lambda x+1)+cx=0$$

Or $$(a\lambda^2+b\lambda+c)x + (2a\lambda+b)=0$$

This should be an identity, that is, true for all $x$.

Hence, $a\lambda^2 + b\lambda +c=0$ and $2a\lambda +b=0$. Notice that the second equation is the differential of the first, hence a repeated root is required.

Because in all other cases your two solutions are $e^{λ_kx}$, $k=1,2$. Only with repeated roots the system of eigensolutions for the homogeneous equation is $e^{λx},xe^{λx}$.

For the case $\lambda = 0$ it is obvious: for any homogeneous linear ODE $P(D) y = c_n \dfrac{d^n}{dx^n} y + \ldots + c_1 \dfrac{d}{dx} y + c_0 y = 0$ we have $P(D) x = c_1 + c_0 x = 0$ iff $c_0 = c_1 = 0$, i.e. iff $0$ is a double root of the polynomial $P(\lambda) = c_n \lambda^n + \ldots + c_1 \lambda + c_0$. For the general case, you can use the Exponential Shift Theorem.

The derivation of this solution is actually so insanely trivial, it's a complete mystery why it isn't taught in most typical introductions to these sorts of polynomial-like differential equations.

In this proof, I'll consider, for simplicity, the differential equation

$$(D-I)(D-rI)y(t)=0$$

And take the limit as $r\to1$. But you can repeat the same process for any arbitrary roots and set them approach each other in a limit, and you'll get the right result.

Most people have the right idea, that you need to take the solution for non-repeated roots, and take the limit as the roots approach each other. This is correct, but it's a mistake to take the limit of the general solution $c_1e^{r_1t}+c_2e^{r_2t}$, which is what most people try to do when they see this problem, and are then puzzled since it gives you a solution space of the wrong dimension.

This is wrong, because $c_1$ and $c_2$ are arbitrary mathematical labels, and have no reason to stay the same as the roots approach each other. You can, however, take the limit while representing the solution in terms of your initial conditions, because these can stay the same as you change the system. You can think of this as a physical system where you change the damping and other parameters to create a repeated-roots system as the initial conditions remain the same -- this is a simple process, but if you instead try to ensure $c_1$ and $c_2$ remain the same, you'll run into infinities and undefined stuff. This is exactly what happens here, there simply isn't a repeated-roots solution with the same $c_1$ and $c_2$ values, but you obviously do have a system/solution with the same initial conditions.

So you instead let your initial conditions be $y(0)=a$ and $y'(0)=b$, and express $c_1$ and $c_2$ in terms of them, so you have

$$y(t)=\frac{ra-b}{r-1}e^t-\frac{a-b}{r-1}e^{rt}$$

Then take the limit as $r\to1$. This is the proof itself, and it's simply algebraic manipulation and a little limits --

$$\begin{array}{c}y(t) = \frac{{\left( {ra - b} \right){e^t} - \left( {a - b} \right){e^{rt}}}}{{r - 1}} = \frac{{\left( {ra - b} \right) - \left( {a - b} \right){e^{(r - 1)t}}}}{{r - 1}}{e^t}\\ = \frac{{(r - 1)a + \left( {a - b} \right) - \left( {a - b} \right){e^{(r - 1)t}}}}{{r - 1}}{e^t}\\ = \left[ {a + \left( {a - b} \right)\frac{{1 - {e^{(r - 1)t}}}}{{r - 1}}} \right]{e^t}\\ = \left[ {a - \left( {a - b} \right)\frac{{{e^{(r - 1)t}} - {e^{0t}}}}{{r - 1}}} \right]{e^t}\\ = \left[ {a - \left( {a - b} \right){{\left. {\frac{d}{{dx}}\left[ {{e^{xt}}} \right]} \right|}_{x = 0}}} \right]{e^t}\\ = \left[ {a - \left( {a - b} \right)t} \right]{e^t}\end{array}$$

Which takes exactly the form $y(t) = \left( {{c_1} + {c_2}t} \right){e^t}$ with $c_1$, $c_2$ that satisfy the initial conditions.

Here's a GIF that confirms that the solution indeed is a limit of the general expression, and not some sudden departure from the solutions for all other roots: (this isn't a particularly surprising visualisation, though -- you've seen it in diagrams showing critical damping and stuff.)