An ideal spring obeys Hooke's law. In order to compress or stretch a spring, some force has to do positive work. This work is stored as elastic potential energy. When the spring returns to its equilibrium position, all this stored energy can be converted back into some other form of ordered energy. Many objects act like springs when they are slightly stretched or compressed. But they do not all act like ideal springs. During the deformation process some of the ordered energy is converted to thermal energy.
A bouncing ball behaves like a spherical spring. As it bounces, kinetic energy is converted into elastic potential energy and back into kinetic energy. If a high-speed camera took a picture at the instant at which the ball's velocity is zero, just before it starts to bounce back, then the ball would appear quite deformed. This deformation stores potential energy in the material the ball is made of. But the energy conversion process in the ball, and also in a real spring, is lossy, and some energy is always converted into disordered energy.