It wasn't the main intention, it was the by-product of the slave trade. The only thing those involved were focusing on was the trade aspect. The fact that it both weakened and established a European presence in Africa was only an incentive to colonize it during the imperialist times.
The only reason it was colonized in the first place was because the the Europeans were dealing with a mineral shortage in addition to increased competition due to flooded markets and Africa was the only untouched continent left.