To my understanding, both. But
@Samori Toure seems more well versed in this subject.
The answer to his question is that people became enslaved in a variety of ways and for a wide variety of reasons, but warfare was by far the way that most people were enslaved as prisoners of war. For example Oyo (Yoruba people) had a civil due to issues of succession of their Alaafins/Obas/Kings. The losing royal families and their allies in Oyo were thrown into slavery. On top of that Dahomey, which had been a small vassal kingdom that had to pay tribute to Oyo realized that the Oyo Civil War had weakened the Oyo monarchy and calvary. That opening allowed Dahomey to attack the western lands of Oyo (modern day Benin and Western Nigeria) with the help of the Europeans.
The Mandingos/Fula/Wolofs had wars and the losers were thrown into slavery. The Ashanti had a war against Dagomba In modern day Central Ghana. Dagomba lost the war and had to pay a tribute in gold each year. The Dagomba could not pay the tribute so the Ashanti allowed them to pay in slaves. So the Dagomba and their kinsmen the Mamprussi and the Mossi attacked various unrelated ethnic groups in modern day Northern and Central Ghana and in Southern Burkina Faso to get enough people as slaves to pay the tribute each year. The Mende, Temne and Limba had wars in Sierra Leone, etc., etc.
There were a large number of people that were captured by a combination of trickery and/or undermining sitting governments. That was the case with the Aro Confederacy in eastern Nigeria and to a large extentin Kongo. The Aro Confederacy used he Juju religion to trick people to going to caves to leave food for their Oracle. Once in the caves the people were kidnapped by ganges of henchmen and taken out through secret passages. The Aro also used mercenaries, notably the Abame, Mbaise, etc., to attack villages in Igboland. In Kongo the ManiKongo/King was undermined by regional chiefs who plotted with the Portuguese to kidnap people, including royal family members and noblemen. Eventually that destabilized Kongo to the point that it imploded and opened the flood gates for slavery in that region. The are many, many other examples.