Law of conservation of energy is used here.
From A to B spring potential energy increases and block's kinetic energy also increases which is due to decrease in gravitational potential energy therefore, decrease in gravitational potential energy is more than increase in spring potential energy. Similarly increase in kinetic energy is less than decrease in gravitational potential energy
A->2
B->1
B to C gravitational potential energy and KE decreases and spring potential energy increases
therefore, rise in spring potential energy is more than both decrease in KE and decrease gravitational potential energy.
C->1
D->1