Look, if the hand were to be SUDDENLY pulled away, the spring would extend MORE than 0.4m and then slowly oscillate until it reaches its equilibrium point.
It's like bungee jumping: the first time you jump, you go down real low, the next time not as low, until you reach an equilibrium position.
In this question, the spring is already lowered into equilibrium position.
If people were to use mgh=o.2kx^2, then they had to know the first time the spring came to rest momentarily.
Now, given that the spring constant is 50Nm, we can do the following calculations.
mgh=0.5kx^2
2 x 10 x h = 0.5 x 50 x h^2
20h = 25h^2
25h^2 - 20h = 0
5h^2 - 4h = 0
h(5h-4) = 0
h = 0.8
Therefore, if the spring was SUDDENLY released, it would fall down to a height of 0.8m and oscillate until it reaches equilibrium at 0.4m