Photosynthesis is a little like the reverse of burning
The idea that chemicals or their bonds store energy needs some clarification. The storage is always relative to some other reachable arrangement of bonds that can be achieved by some actual chemical reaction. So, if we say a specific compound "stores" energy we need to specify relative to what.
If we say coal stores energy what we usually mean is that we can burn coal (crudely, impure carbon) in air in a reaction that creates carbon dioxide and a large amount of heat. This is a simple widely observed and widely used reaction that we know releases energy.
But why? The energy is released because the total amount of energy tied up in the bonds of carbon dioxide is less than the energy tied up in the oxygen molecules and the solid carbon of the coal. When we burn coal that energy appears as light and heat we can use to warm our homes. We could, under different circumstances, react coal with other chemicals and get different outcomes (i'm sure coal will also burn in fluorine). But since the air around us has ~20% oxygen, burning coal is a very convenient way for us to produce heat.
The reason we say coal "stores" solar energy is because photosynthesis allows plants to drive the reaction in the opposite direction. Crudely (photosynthesis involves some very complex details) plants use the energy from sunlight to allow them to make a range of complicated carbohydrates by taking carbon dioxide from the air and water from the ground. (note photosynthesis also releases oxygen which is the main reason there is any in the atmosphere). The bonds in those more complicated molecules have higher net energy compared to the carbon dioxide and water they are made from and also compared to the products they would create if we burned them in air (wood burns too).
Coal is basically old plants that have been transformed by geological processes to impure carbon. So the ultimate reason we can burn it and release energy is because ancient plants captured energy from the sun to make more complicated molecules necessary for their growth. Burning is like the opposite of photosynthesis.
Coal "stores" energy because the arrangement of bonds in carbon and oxygen have higher energy than the arrangement in carbon dioxide and, in an atmosphere containing oxygen, we can release that difference as heat by burning the coal. But the ultimate reason the coal is the way it is is because plants made other complicated, higher energy, molecules by capturing solar energy to build them. Hence it is not unreasonable to say that coal "stores" energy from the sun (though it is oversimplifying a lot).