Racism comes out of our negative experiences like the one that your describe, but it also comes out of wanting to maintain relative position to the people around us. The Japanese raped the Thai women to terrorize them and keep them and the other Thai citizens in their place through fear, violence and threat of violence. That’s how a dominance hierarchy is maintained.
In other words, the issue is more with the hierarchy and how whatever people happen to be near the top of it in any given situation behave, then those people in the abstract.