The first thought that comes to mind is European imperialism, but why was those said countries weak enough to get colonized in the first place?
Well it's more complicated than a single reason. Did European imperialism play a role? Yes, but to say that is the total root cause would be grossly oversimplifying the issue. The Mali empire would collapse in the early 17th century, ushering warfare amongst competing successor states. The greater region West Africa in the late 17th and 18th centuries was a tumultuous place. Morocco was seeking a greater role in the region and took control of Timbuktu from the Songhai In 1591. This is while western powers provided weapons in exchange for slaves, thus fueling conflicts along the bight of Benin as Portuguese slave traders and Merchants had been operating there since the late 15th century. Since independence, lack of stable governance and civil war have hampered west African states from developing.