Dear Student,
When the spring is maximum expanded, then its potential energy or the potential energy stored in it is maximum and kinetic energy of the mass attached to the spring is zero.
Similar is the case when spring is maximum compressed.
Regards,
Manoj Singh