Those are two very different questions and need to be separated. But unfortunately, too many Europeans and their European cultural heirs prefer to conflate the two for cultural and economic advantages.
Focus first on Africa. Africa needs electricity, affordable, reliable, and continuous energy to break the industrialization barrier. That means that coal must be the mandatory first step. As a fuel, it’s readily available, cheap, and requires minimum technology and capital investments.
Yes, we turned our nations into an ecological dump for decades in the process. I recall the soot and filth in the London air. I saw rivers in Pennsylvania catch fire. I felt the acid air of Taipei and Seoul burn my throat and lungs. But there was a long-range, unspoken view that this is what had to be done to better humanity. So these countries built the industries and commerce that gave us the foundation for our modern world and the health and prosperity it empowered.