In terms of origins and transmission, racist ideologies depend on the creation of stereotypes and their transmission through agencies of socialization. (In societies where racism is formally institutionalized, such as during the Jim Crow era in the U.S., law is also an important avenue of transmission and legitimization).
Racists rely on stereotypes to create otherness (you are not one of us), because stereotypes permit them to dehumanize their victims. These stereotypes can be, both, positive (intelligent, industrious, ambitious), and negative (lazy, dumb, thieving, etc.), but above all, in the arsenal of all racists three stereotypes are universal and salient: one has to do with dirt, the other with sex and the third with trust. For example, those who have monopoly of power and resources in this country, the English, have portrayed all these groups at various times in history as unhygienically dirty, animalistically oversexed, and highly untrustworthy: Native Americans, African Americans, Irish Americans, Italian Americans, Jewish Americans, etc.
But where do stereotypes come from? They come from those who are involved in producing the content of what we today call the media (comprising electronic social and mass media, and traditional media: books, cinema, television, music, theater, newspapers and magazines, radio, museums, etc.): writers, actors, musicians, entertainers, artists, scholars, museum curators, travelers and explorers, etc. All of these people are involved in the creation, dissemination and maintenance of stereotypes. As stereotypes become widespread in a society over time, other agencies of socialization besides the media become involved: the family, the church, schools, and so on.