Energy cannot be created or destroyed, only transformed from one form to another. The total energy in an isolated system remains constant.
A simple pendulum is a classic example of energy transformation. As the pendulum swings downwards, it loses gravitational potential energy ($PE$) and gains kinetic energy ($KE$). As it swings upwards, the reverse process occurs.
In reality, complete isolation is impossible. Air resistance and friction at the pivot slowly transform the pendulum's mechanical energy into thermal energy (heat), dampening the swing over time. The energy isn't lost, just transformed into a less useful form.
Gravitational potential energy depends on an object's mass and height. As it falls, this energy is converted linearly into kinetic energy. If it drops without friction, all $PE$ turns into $KE$.
Energy can also be stored in the deformation of elastic materials, like springs. The energy stored is proportional to the square of the displacement $x$ from equilibrium.