I think it's important to note that what people relate to most in Star Trek are the humans. The aliens are used as a way to challenge human ideals.
Some examples of this:
TOS Let That Be Your Last Battlefield, where one alien is black on the left, but the other is black on the right. They hate each other because of it. Kirk's reaction isn't 'well we shouldn't judge them', he does judge them. The entire Enterprise does. Those aliens' intolerance for skin colour is a completely foreign concept to this idyllic human future. In the end, when they find out their entire race died in a race war, the enterprise leaves them to their intolerance and hate, because they know where it's headed.
On more than one occasion, Kirk has used offensive language towards Spock to inform him he is in a bad situation; because he realizes Spock knows him well enough that he would never earnestly mean any of it.
Kirk's own hate towards the Klingons is also challenged in The Undiscovered Country. In fact Gene Roddenbury didn't even WANT Kirk to be racist towards them in the first place, but it was done anyway because it added drama.
The Cardassians, in almost all of their depiction save for about two individuals, are depicted as xenophobes. They're are snake like, have no conscience and it is implied they enjoy torturing others. But these traits aren't glorified. They are always cast in a negative light. Bashir and Garak seem to get along for the most part, but when push comes to shove, Garak is willing o take actions Bashir reviles and abhors. We aren't supposed to think Garak's actions are good or honorable.
In The Outcast we are shown a society that is absolutely against individuals who identify as male or female, and use some form of hypnotherapy to 'normalize' those who do. This entire episode is an analogy towards how bigots against LGBT would go so far as to try and 'normalize' their children by sending them to camps and brainwashing therapy to try and 'get rid' of any homosexual tendencies.
This race of aliens is cast in a negative light. Riker wants to save Soren from her intolerant people, but he's too late. In the end, the Prime Directive means they cannot interfere with the J'nali's society.
Even Chief O'Brien, his intolerance of Cardassians is often challenged and he is called out on it. He doesn't want to work with them, he doesn't want to have to even interact with one. Even when they are the victims, he finds a way to vilify them. He's one of those 'I'm not racist BUT...' people. Keiko doesn't agree with his views, and on more than one occasion has challenged him on the subject. Few agree with him, save for the Bajorans who just came out of a 60-year occupation.
But the point is, Starfleet isn't supposed to tolerate intolerance. That's why they have so many rules surrounding why a planet can or cannot join the federation, the most important of which were:
'...values of benevolence, peaceful co-existence and co-operation, the rule of the law, and equal rights and justice'.