When the sun's energy was utilised to separate carbon and oxygen how can the coal bonds store it?
You use the word 'utilised' as if this means the energy is used; it no longer exists. But energy never disappears, it just changes form. When you take a rubber band and pull the ends apart, you consume (or better: move) energy, which is stored in the rubber band. If you now release one end of the rubber band it will snap together, the energy is released. Imagine there is a rubber band between the oxygen and the carbon atoms*, by separating the two, you add energy to the system. By combining the two, you release that energy again.
*The analogy does not hold for very long, moving the atoms further apart will not increase the energy stored in the system.