Now, it can become a sin if one embraces and cultivates those thoughts. But, even that would not lead to firing the teacher. Even acting on those thoughts privately would not lead to a firing. It is the taking of a public act condemning Church teaching which leads to the firing.
I certainly understand your point about PC police. Happily, the Catholic Church is not trying to use the power of the state to force people to think like Catholics. And, the Catholic Church is not calling for non-Catholics to be fired from their non-Catholic jobs because they are not Catholic. So, there is a huge difference between the two groups that makes the Catholic Church far more benign than the PC police.
To your point about discrimination: This particular case (the firing of the teacher) is a case of an organization policing its own beliefs, and everyone accepts that that is permissible. We wouldn't make a Muslim school hire a person who is anti-Muslim as a teacher of their children. That would not be considered "discrimination" for a Muslim school to hire only those who do not publicly oppose Islam as teachers. And, it would not be considered discrimination if the Catholic Church fired a teacher who became a stripper; likewise, there is no discrimination when firing a teacher who becomes a public advocate of a gay lifestyle. This is about scandal: a person purporting to promote Catholic teaching but leading people astray from it. This is just the Catholic Church saying what is Catholic and what is not Catholic. Every organization gets to do that.
To your point that you find it hard to believe any god would declare something to be wrong that didn't harm someone: I certainly get your point. When I was an atheist, I too railed against "victimless sins." That is a bigger issue which requires more time to respond.