This internalised form of racism is an invisible presence in our psyches, and some of us don't even realise it's a factor in how we perceive ourselves and others. Thus, for instance, black guys (not only in Africa) think their attraction to light-skinned girls is just a matter of taste, and some who lighten their skin can't articulate why they do so beyond saying that it's just prettier, as though skin lightening were akin to putting on lipstick. It's a matter of identity, self-worth and self-acceptance, that, in some respects, is even existential.
There is some evidence of colorism (system of privilege, discrimination and hierarchies based on social meanings attached to skin tone) in Africa before contact with Europeans in the 16th century, but by and large, Africans used shared culture, language and traditions, rather than skin tone, as a means of identification. But part of the process of creating an European empire was to define the European self in contrast to everyone else. How could you justify dominating and enslaving other people if you didn't tell yourself you were better in every way? Europeans placed themselves at the pinnacle of the human race and dark-skinned Africans at the very bottom. To be black was to be primitive, backward, inferior, dirty, ugly, evil, devilish, deviant, corrupt and unappealing, while to be white was to be virtuous, beautiful, refined, humane, intelligent and godly.
By the nineteenth century, spurious scientific "evidence" was being produced to support this dichotomy, thereby providing an ideological justification for colonialism. It also provided a means of control: tell the lighter-skinned black Africans that they are more beautiful, intelligent and industrious than their darker-skinned brothers and sisters, and soon you will create divisions that make control easier. A 1930 French ad for Dirtoff showed a dark African man washing his hands, with the soap washing away his blackness. Such ads were common in the late 19th and early 20th centuries. Blackness had become a pathological condition - there was something fundamentally wrong with you if you were black - while whiteness became the paradigm, the standard, the ideal, and who doesn't want to be ideal?