Why did the African Moors go to Southern Europe instead of staying in Africa?

All Religions and Gods reflect the mentality and culture of those who create or come to dominate those Religions.  Because Gods and Religions are man-made, they become tools of men; just like all other man-made inventions. 

Some cultures have what we call Hyper-Aggression, or the drive to dominate, attack, expand, and consume well beyond their basics needs.  Hyper-Aggression has been the cornerstone of Western Culture.  So, Judaism, as practiced by the  Ashkenazim (European Jews) became a religion of expansion and conquest.  Christianity, as it was consolidated and dominated by Europeans, starting with the Romans, became a Religion of expansion and conquest.  As Islam was birth from and rooted in both Judaism and Christian mythology, and Arabs have always displayed the Western Hyper-Aggression mentality of their European cousins, it also followed a path of expansion and conquest.

All people all over the world invented Gods and Religions, but the Gods you find who’ve crossed vast territories and were imposed on many different cultures are Gods that were invented or captured by people bent on conquest, and they use those Gods as tools or weapons of conquest.

So as Islam expanded across North African, they took advantage of the already existing trade routes, technologies, and wisdom of those they invaded, Africans had been traveling the world, trading and interacting with other cultures long before Islam’s invention, when Islam imposed itself on the Africa, Afrians impated and changed Islam just as Islam impacted and changed Africans. 

The Moors took African culture and civilization, along with Arab proclivities toward conquest and expansion in conquered regions of Southern Europe. 

(Again, this is a very attenuated version of the history, sorry, but I hope it helps.)