How does a compressed spring can do work?
See explanation below
When a spring is compressed then the work done on it, is stored in form of strain energy within the elastic limit. Elastic strain energy can be released back by the spring to the surrounding which can perform an equivalent work on external agent.
Thus a spring compressed within the elastic limit releases its strain energy to do an equivalent amount of work i.e. a compressed spring can displace a finite object through certain distance .