You guys are making it more complicated than it needs to be,
The problem is about how much energy is stored in the spring when the end is moved horizontally a distance x.
So you want at the end the answer in terms of x.
That is, if I pull the spring end horizontally a distance x, I plug x into the formula to get the energy stored.
The energy stored depends on the extension of the spring δe, so you need first mathematically to find the extension in terms of x.
You then have δe in terms of δx
When you have that, mathematically, you integrate the formula with respect to x, as x is now the variable, not the extension.
The resulting formula gives you the energy stored as a function of x. Which is what you want.
There is no point in integrating wrt e as you don't know e. You only know the value of x, which e depends on.