There's actually only one reason.
They can't get credit for anything else.
African nations are exceptionally capital poor. Basically all projects are funded by foreign investment banks.
Last decade and a half was significant reduction on any power plant infrastructure loans that were for anything other than solar and wind, of which time after 2015 (Paris Agreement) was almost a total ban. This hit even the one exception in Africa: SA, and is one of the reasons for their constant blackouts. Though as is the case with this nonsense in most of Africa, it's far from being the only cause.
So last decade and a half, Africans were screaming at Westerners to please let them have loans so they could have reliable sources of energy so they could have stable grids like Westerners do. None were given. Meanwhile Chinese basically farmed them as a location to dump their massive solar oversupply for last decade or so.
It's all about access to the capital. Africans got whatever got funded. That's it.
In case you're wondering why everyone who wants electricity has these small diesel generators in Africa, this is why. Intermittents ensure that grid cannot be stable, while omnipresent copper thieves put massive nails in stability's coffin.