In the following situation:
A 700 g block is released from rest at height h 0 above a vertical spring with spring constant k = 400 N/m and negligible mass. The block sticks to the spring and momentarily stops after compressing the spring 19.0 cm. How much work is done (a) by the block on the spring and (b) by the spring on the block?
When thinking about the work done by the block on the spring. The block pushes against the spring for a displacement of $ x = 19\cdot10^{-2} m $.
In my understanding, the work done by the block into the spring is $ W = mgx $ as the block is using its weight to press against the spring and produces a displacement, $ x $.
And, on the other side, the work done by the spring on the block is $ W = -\frac{1}{2}kx^2 $
However, in some solutions, I'm finding that "the work done on the spring is the same as the work done in the spring by the block as is an isolated system and there's no dissipation of energy". I'm confused by this.
Why the work is the same?