>>17937704 (OP)
Because north african muslim armies and courts had the occasional black slave/servant/freedman with them, who ended up catching the attention of europeans due to their exotic appearance, then proceeded to basically get turned into an insulting stereotype and a way to otherize north africans in an obvious, visible way that can easily be depicted in art.
I.E, it was quite literally the medieval equivalent of americans on 4chan jokingly depicting Europeans as Muslims due to modern refugee migration, or people on /int/ depicting argentinians as pitch black africans as a way to parody their tendency to claim european ascendancy. They know it isn't actually true in reality, it's just banter.