**Observations**

Start by trying to understand what is happening here.

Block #2 is moved to the left **very slowly** from infinity, held in place by some external force. At each step block #1 is in **quasi-static equilibrium** : the electrostatic (ES) attractive force to the right is matched by the elastic force to the left.

The natural response of block #1 to a sudden change in the position of block #2 is to oscillate : the ES force is suddenly bigger while the elastic force remains the same. Block #2 oscillates until it loses its KE somehow and finds a new equilibrium position. Regarding the spring and 2 blocks as *the system*, the external force does -ve work on this system, taking away the kinetic energy as it develops.

So energy is not conserved, and since it is not obvious how the unknown external force varies, the work-energy theorem is not useful here. What we can say is that the KE removed equals the total PE stored at equilibrium (which will be -ve), but that is not useful either.

Your observation that $r=0$ when the blocks collide is correct and warns us that block #1 cannot be in equilibrium at all times. **At some point the equilibrium becomes unstable**. We have to find out when that happens.

Suppose at this point the separation between the blocks is $r_0$ and the extension of the spring is $x_0$. At this point of unstable equilibrium a small displacement of block #1 causes it to accelerate the rest of the distance $r_0$ towards block #2 while block #2 is held stationary by the external force. Block #1 collides with block #2 and the KE it gained is again dissipated somehow, but we don't need to know what this KE is. The final extension of the spring is $x_0+r_0$.

**Solution**

The resultant force on block #1 is $$F=\frac{KQq}{r^2}-kx$$ where $K$ is the Coulomb constant. This is zero right up to the unstable position so $$x_0=\frac{KQq}{kr_0^2}$$

If block #2 is held fixed, an increase of $dx$ in $x$ is equal to an increase of $-dr$ in separation $r$. That is, $dr=-dx$. Therefore equilibrium becomes unstable when $$\frac{dF}{dx}|_{r_0}=\frac{2KQq}{r_0^3}-k=0$$ $$r_0=(\frac{2KQq}{k})^{\frac13}$$ $$x_0=\frac12 (\frac{2KQq}{k})\frac{1}{r_0^2}=\frac12 r_0^3 \frac{1}{r_0^2}=\frac12 r_0$$

The final extension of the spring is therefore $$x_0+r_0=\frac32 r_0=\frac32 (\frac{2KQq}{k})^{\frac13}=\frac32 (\frac{Qq}{2\pi \epsilon_0 k})^{\frac13}$$