Bit more complicated than that. Slavery was the basis of their entire economy, as the superwealthy King of Benin fired back at Europe when Europe tried to make African slavery ilkegal.
To be fair, Europe only made skavery illegal when it was whites suffering. 1-3 million white Europeans were kidnapped and enskaved by northern African caliphates over the years, finally getting so bad that Europe declared sjavery illegal and went to war with Africa to enforce it. (1st Barbary war). All the major European nations went, Captain Edmund pellew bombarded the capital of Algiers and freed 1800 Europeans held in a cave there.
Africa didn’t stop however and kept up their slaving. Si Europe went back to make them quit this time. (2nd Barbary war). For this one the US also got involved though they gad been too busy fighting for their own survival during the 1st Barbary war.
After the 2bd Barbary war, this time Europe would see African skavery was stoooed once and for all. France agreed to take control of the caliphates and started the French foreign legion whose job it was to stop uprisings, but also to route out any remaining pockets of slavery.
The start and cause of colonialism’ was to ensure Africa did not revert to its slaving ways.
Sure Europe only stopped Africa enskavibg and selling its own people as a collateral goal to stop it from kidnapping and enslaving white Europeans as they travelled. If Africa had stuck to only selling their own people Europe may never have bothered. But the Muslim caliphates loved to have their harems full of white women.
An easy target were the Eastern European nations and some white slaves from that region became historically important or famous concubines and even sultanas.