I tend to use the example of a person being mean to encite hatred to help simplify for uneducated or children to better understand.
The reality is most racists don't learn to be racist by bad encounters. Those are usually just unfortunate and rarer circumstances that simply encourage or justify a bias for someone.
Racism is in fact typically taught within a specific kind of setting. Typically either equal in race population. Or more commonly in white neighbourhoods. Virtually mentally segregated from the rest of the world but their own personal issues.
So in most cases it is "fear". But rather a fear of change. More accurately; it is similar to teaching a child about mathematics or language. It all depends on who their teacher is and what they consider true.
Thus the never-ending generational racist mindset is powerful and makes its roots eithin the child brain and early. And as far as neural wiring works; this becomes basically instinct if nothing is done before reaching full adulthood.
Which is scientifically determined to be somewhere around the age of 25. When we consider typical human growth of the brain, body, and organs in general.
Some day I will write a book about "white culture" for lack of a better term.