**Revised Answer**

We must assume that the spring is pulled suddenly (ie jerked) from the stationary position. Then the block oscillates while it moves to the right. We have not reached a steady state in which the spring and block move with the same constant velocity $u$. This could happen if energy is lost during the oscillations of the spring (hysteresis).

The steady state could also be reached by applying an infinitesimally small force to the end of the spring (ie it is **not jerked**). This force very very gradually accelerates the block up to velocity $u$ while keeping the extension of the spring very very small. The force is then removed. The block and spring are now moving together with velocity $u$ while the tension in the spring is zero. In this scenario the energy stored in the spring remains zero throughout the subsequent motion, and the total energy of the mass-spring system is the KE of the mass which is $\frac12 mu^2$.

The total energy in the system is not constant in the ground frame of reference $S$. In order to provide a constant velocity $u$ to the end of the spring, a sinusoidal pulling force must be applied. This alternately adds and removes energy from the mass-spring system. See discussion about this problem in the Stack Exchange chatroom.

However, the total energy is constant in the frame of reference $S'$ in which the free end of the spring is fixed. No work is done on the system in frame $S'$, because the point at which the force is applied does not move. The extension of the spring is the same in both frames, so the elastic PE is the same. But the kinetic energy is different.

Compare the energy of the system at 4 stages in the oscillation cycle, from both frames of reference :

**Stage 1 :** In frame $S'$ the spring is initially at its equilibrium position (so there is no elastic PE stored in it) and the block is suddenly projected to the left with velocity $u$. The total energy in frame $S'$ is the KE of the block, which is $\frac12 mu^2$. In frame $S$ the block is at rest so the total energy is $0$.

**Stage 2 :** In frame $S'$ the block moves to the left some distance and comes to rest at its maximum amplitude. Its KE is zero and the elastic PE stored in the spring is $\frac12 mu^2$, because the total energy is constant in this frame. In frame $S$ the elastic PE is still $\frac12

mu^2$ because both observers must agree on the extension of the spring. Its velocity in frame $S$ is $u$ so the KE is also $\frac12 mu^2$; the total energy in this frame is $mu^2$.

**Stage 3 :** The spring pulls the block back to the equilibrium position where again in frame $S'$ it has velocity $u$ but now **to the right**. This is its maximum velocity in frame $S'$. In frame $S$ the velocity is now $2u$ so the KE is $\frac12 m(2u)^2=2mu^2$. The PE is zero so the total energy is $2mu^2$.

**Stage 4 :** In frame $S'$ the block continues moving right, compressing the spring until it again comes to rest. The PE is again $\frac12 mu^2$ in both frames, because the KE is zero and the total energy must be $\frac12 mu^2$. In frame $S$ the velocity is $u$ to the right so the KE is $\frac12 mu^2$; the PE is still $\frac12 mu^2$ so the total energy is $mu^2$.

**Stage 5 :** In frame $S'$ the block is pushed left and returns to its equilibrium position where its velocity is $u$ to the left. We are back to Stage 1. The cycle is complete.

The total energy in the system oscillates between $0$ and $2mu^2$.