There's a couple of things at play here (renewable energy is my industry).
1. Renewable energy, especially solar, is cheaper *sometimes*. How much sunlight is there in that area? The difference between New Mexico and Illinois for example is almost a factor of 2. That is a massive factor. Other key factors include cost of labor, and (often underestimated) beautacratic red tape. For example, in India it takes about 6 weeks to go from "I'll spend $70 million on a solar farm" to having a fully functional 10 MW solar farm. In the US, you'll need something like 30% more money, and it'll take 9-18 months. In some parts of Europe, it might take 4-5 years and cost double to triple.
All of those things matter a lot.
2. For the most part, capex is the dominant factor in the cost of energy. In the case of fossil fuels, we've already spent the capex, so while it's more expensive over a period of 20 years to keep using coal, if you are just trying to make the budget crunch for 2025 and 2026 it might make sense to stay on fossil fuels even if renewable energy is technically "cheaper".
3. Energy is just a hard problem to solve. Grid integrations, regulatory permission, regulatory capture, monopolies, base load versus peak power, duck curves, etc etc. If you have something that's working (fossil fuels), it might be difficult to justify switching to something that you don't know how it will work.
Solar is becoming dominant very quickly. Give it a little bit of time, and you'll see more and more people switching to solar over fossil fuels.