This thread is making the mistake of grouping North Africans with Southwest Asians.
North Africans possess African ancestry because they are fundamentally an African population.

They are bioculturally rooted in the African continent and are therefore genetically, culturally, and linguistically intertwined with other African populations. Only in Africa, are people indigenous to the continent questioned about their affiliation with other groups indigenous to the continent. North Africans first and foremost, are the descendants of Saharo-Tropical African populations. Meaning, the foundational component of the N.African population expanded into the region from further south. The oldest parental lineages (both yDNA and mtDNA) in N.Africa are approximately ~20,000 years old and are downstream mutations of lineages found in the general NE African region, Sudan and the Horn of Africa. Is it a coincidence that both Egyptians and Maghrebians speak Afrasan languages, of the Egyptian and Berber sub-groups? Highlighting at a linguistic level, an expansion of Afrasan from NE Africa into North Africa. This together with archeology and genetics indicates a migration from the area of the Eastern Sudan/Eritrea/Ethiopia into North Africa. With it being more continuous in Egypt in contrast to the Maghreb, but that should be obvious, no? They are then a result of admixture via Western Eurasia and West Africa. With the both components initially penetrating the region relatively early, 10,000-13,000 BP and 15,000 BP respectively. There would have then been some historical admixture as well from both sides, but it's likely that the bulk of the admixture would have already taken place. Outside of Egypt really, most of the non-indigenous admixture is historic... entering the country mainly during the Greco-roman and Islamic era's. These two components have a negative-positive relationship with one another, with West African admixture decreasing when Eurasian ancestry is more dominant and with Eurasian admixture decreasing when West African admixture is more dominant. North Africans are therefore an old world mulatto population to put it simply, they are the result of admixture. According to Tishkoff et al. 2009 and 2009 the Mozabite Berbers are 50% Eurasian-African Saharan (the end result of the bidirectional gene-flow between North Africa and Western Eurasia), 35% Cushitic (the foundational base for the population), and 15% West African (a late arrival into the scene).
Phenotype doesn't equal genotype.

Riffian and Kabyle Berbers just so happen to resemble each other because they inhabit a similar environment, a colder and mountainous environment. Atlas and Mozabite Berbers resemble each other because they inhabit a similar environment, a more arid and humid environment. It is not a coincidence that they resemble each other. And they are all isolated and impoverished groups, so you can't blame it on the slave trade. The Slave trade didn't leave pan-national or pan-regional genetic alternations, consequences of the slave trade are for the most part individual and are regionally sporadic. Northerly NW Africans likely all group tightly close to each other, with some regional variations... but still relatively close.
Southwest Asia is a different story. These people are not African and are not the direct descendants of Saharo-Tropical African populations. They just so happened to have taken part in the bidirectional flow between North Africa and Western Eurasia. There is a fundamental difference between Semitic speaking SW Asians and non-Semitic speaking SW Asians. The only real exceptions being the Assyrians, Druze, and recent Jewish populations; who happen to be more like SW Asians in Turkey, the Caucasus, and Iran. NE African admixture likely arrived relatively early in the region with the arrival of Semitic languages and particular parental lineages. Something supported by archeology. This likely represents about ~15-20% of the genetic diversity among most Semitic speaking SW Asians outside of Yemen, where it likely reaches ~30%. Now, there hasn't been any peer-reviewed studies that really delved into the above subject at a autosomal level, but there has been some amateur runs that support my theory. One of Dienekes most recent STRUCTURE runs matched those of a particular amateur geneticist. While the frequencies of the Ethiopians, Saudis, and Bedouins were likely not representative of reality, the findings of the other SW Asians matched the findings of this particular individual. NE African admixture then drops off when you move into Turkey, the Caucasus, and Iran... where it is only found at a frequency of 5-10%. Assyrians and Druze also possess lower frequencies of this particular component, possibly indicating a language shift? Jews are Jews... their historical adopted homes likely played role in their decreased frequencies of the NE African component, if not they would have likely resembled Palestinians.
The West African admixture in the M.East is most definitely from the Slave trade. It's sporadic as slave era admixture should be and is only really significant among populations with a large slave African descended population, like Basra Iraq and southern Iran. It likely peaks in Yemen and Oman at around 15-20%, but drops to less than 5% in Lebanon and Syria where the slave trade was not that important. According to one of Dienekes most recent runs, West African admixture was found at a frequency of 5-7% among SW Asians in 4 countries/regions (Bedouins, Palestine, Makrani Pakistan, and Jordan), outside of Yemen where it reached 17%.
I hope this doesn't cause any controversy or backlash. The above is supported and does have a academic basis.