Force and Energy
If we ignore damping effects, we can conclude that there are only two forces acting upon the mass vibrating on the vertical spring - - the force of gravity and the spring force. Since the spring is stretched downwards in all three positions, the spring force is directed upwards. The force of gravity is directed downward. Each of these forces are conservative-type forces that serve to change the potential energy into kinetic energy (and vice versa) without changing the total amount of mechanical energy. So if we ignore the effects of friction and air resistance, we can conclude the total mechanical energy (TME) is conserved.
Gravitational Potential Energy
The gravitational potential energy (PEgrav) is the energy stored due to the vertical height of the mass within Earth's gravitational field. As the mass is elevated to higher vertical positions, the gravitational potential energy increases.
Elastic Potential Energy
The elastic potential energy (PEspring) is the energy stored in the mass-spring system due to the amount the spring is stretched or compressed relative to its relaxed state. The amount of elastic potential energy is proportional to the square of the stretch distance. The relaxed state is shown in the first of four snapshots of the spring. The further downward the spring stretches, the more elastic potential energy that will be stored in the system.
Kinetic Energy
The kinetic energy depends upon the speed of the object. As the speed of an object increases, its kinetic energy will increase. The equilibrium position of the mass on the vertical spring is location B (stated in the problem). When the mass located above this position, there is a net downward force upon it. So as it moves upward above location B towards location C, the mass will be slowing down. And as the mass moves downward from location C towards location B, it will be speeding up.
When the mass is located below the equilibrium position (B), there is a net upward force acting upon it. So as the mass moves downward above location B towards location A, it will be slowing down. And as the mass moves upward from location A towards location B, it will be speeding up.