I'm picturing a vertical mass-spring system. This system is at rest at its equilibrium point. If we pull the mass downward, we remove potential energy from it. If we let go, ut will have no kinetic energy and a minimum potential emergy for a moment. The spring will have energy stored at this point.
As the mass goes upward to the equilibrium point, the spring loses all its stored energy, the mass gains maximum kinetic energy, and the mass gains potential energy. I find no trouble here. If we continue, the mass will continue upward to a distance from the equilibrium point approximately equal to the distance we pulled it down initially. Now, the block will have maximum potential energy, as it is highest off the ground, the block will have no potential energy, and the spring will have maximum potential energy stored again.
Comparing the top and bottom of the path, how can the block have the same kinetic energy and the spring have the same potential energy, but the block gains potential emergy as it goes upward? Where is this energy coming from? I'm assuming the spring is massless and we have no friction, air resistance, etc.