As you cool a system, you are removing energy, yet as water transitions to a solid, it expands, exerting sufficient force to rip through metal, for example in residential copper water pipes that freeze. Where does that energy come from?
The change from liquid to solid releases some energy as (stronger) bonds are made between the water molecules - latent heat of fusion. The expansion pushes back the surroundings and work is done at the expense of some of the released energy when the bonds are being made.
The internal energy (potential energy) of the water decreases as heat is abstracted from the water and the water (ice) does work on the surroundings in expanding.
As the bonds are formed the molecules are closer together than their equilibrium separation ie there is “elastic” potential energy stored in bonds and when the containing vessel is ruptured those compressed bonds expand just like a compressed spring releasing energy when it expands.