You're assuming that countries with no existing infrastructure would build it the same way we did.
If you're a small African village, having a couple of solar panels is way better than a coal power plant. You don't need roads and trains to continuously ship in coal or the lights go out. You can get more buildings electrified before you have a stable power grid because you have decentralized generation. You can have small/cheap storage batteries because you build infrastructure to begin with that demand shifts to during the day -- pressurize a water tank during sunlight hours so that you have running water through the night with no nighttime power consumption. Use high efficiency LED lighting to minimize how much battery you need. And so on. All of which is cheaper when you design for it from the start.
Whereas if you're at the stage of India or China with a real power grid where you have to start worrying about baseload, that's when you build nuclear. Assuming that declining storage costs don't eventually make even that unnecessary.
About the only thing fossil fuels are still good for is as an emergency battery for long periods of low generation from renewables. But then you're not building them as baseload power generation and they only get run one week out of the year. And even then it's still not coal, because you can do that with natural gas, which is currently cheaper (and cleaner and emits less carbon).