When the mass is slowly lowered, the mass does not gain velocity. Therefore
at equilibrium balancing the forces we get
k d = m g
d = m g / k ------------------- (1)
If the mass is let fall freely, the mass gains and looses kinetic energy.
work done by the gravity + work done by the spring = change in kinetic energy.
mg h - 0.5 k h2 = 0
h = 2 mg / k = 2 d