Answer :
Work.
The way the energy changes when compressing or extending is the result of work being done on the spring or by the spring.
The way the energy changes when compressing or extending is the result of work being done on the spring or by the spring.