That's right. And when you have a morally unacceptable thought you stop it going any further. You say to yourself 'that's a horrible thought, I won't pursue it' just like you might have thoughts of hitting your child or swearing at your boss. It's fine and natural to think it but you stop yourself doing it. Every adult is capable of managing their own thoughts.
I suspect many people are actually not all that aware that this is a good idea, or even possible.
Along the same lines, many people don't realise that thoughts are not always benign, and the kinds of thoughts you chose to encourage can affect you in negative or positive ways. They can change your responses and perceptions.
Since the 60s there has been a significant narrative that says that if something only remains in your thoughts, it is simply fantasy and has no further effects. The idea that an idea that is pursued a lot in the mind is very likely to influence behaviour to some extent isn't really explored in any depth, although people often talk about mind body connections in other contexts. During the same period, the idea that mental self-disapline is something that we need to practice to get better at, has also gone by the wayside.
I suspect many people would have little idea of where to start in avoiding thoughts like that at all, they have no experience of trying to do something like that. When people do find themselves having very disturbing thoughts they often try and repress/deny them rather than suppress them in a more conscious way, as they don't know the latter is possible and they are frightened of the thoughts, which is not necessarily a great approach.