There are a few different aspects.
One is that Europe -- and in particular, some of the richest parts of Europe -- gets a material fraction of its energy from Russia. Sanctions from Europe eliminated some of this supply, and retaliation from Russia eliminated more of it.
The timing coincides with a period when Europe was already going to have significant energy shortages, as Germany has been aggressively decommissioning its nuclear generation capacity and Europe generally has been trying to "decarbonize" its energy markets in a manner that removes carbon-intensive capacity much faster than it builds out new renewable capacity (thereby reducing the total amount of energy produced).
On top of that, European populations are growing (a little), which produces (a little) more energy demand.
Europe does produce coal, but it's been producing less and less over time, due to the decarbonization efforts I mentioned above, and also because some of the mines are quite old and getting somewhat mined out. (Poland, for example, still produces lots of coal, but the cost to produce it keeps going up as they have to dig further and further to get to more -- new mines are not opening)
In addition, (very realistic) fears of a shortage coming in the winter have led to people trying to purchase now as much as possible the energy that they will need in the winter, which is why prices are skyrocketing now rather than waiting until the shortage actually happens. (You can see this most acutely in Poland, where people are literally waiting in their personal vehicles in a three-day-long line outside the local coal mine to purchase their winter allocation of heating coal. (The government in Poland has already begun to ration coal, allowing each household to only purchase their fixed allocation from the mines).
Some energy demand is highly "elastic" -- that is, if the price goes up, the demand falls. If you use energy to make stuff, if the cost of the energy goes above the value of the stuff, you stop making the stuff. But a lot of the demand is pretty inelastic -- a family in a place with a cold winter will probably buy enough energy to heat their home at least to about 55F at almost any price that isn't totally ruinous, and will continue to buy energy to heat to at least about 50F even at ruinous prices.
That means that when there's a shortage, prices will move up gradually to a point, and then suddenly they'll spike very high very fast. That's because at first, as prices go up, demand falls -- people and companies stop using as much energy and start both being more efficient and also foregoing energy-intensive activities -- but after a certain point, higher prices don't drive out that much more demand, because all of the uses of energy that people are willing to curtail have already been curtailed. At this point, prices spike very high very fast, as each new increase in price only reduces demand very slightly, and so the shortage remains.
If prices stay this high for an extended period, people can take drastic actions to reduce their use (for example, multiple families could move into houses, so that there were fewer homes to heat, or they could, as one German minister suggested, only heat a single room per house and sleep all in one room at night in the winter -- but they won't do these things unless they have no choice, and in some cases they can't do them quickly anyway.