moralizing
Moralizing is when someone tries to influence or control other people by telling them what is right and wrong. They often use moral terms like good and evil to do this.
The teacher was moralizing the students, telling them what they should and should not do.
The politician was moralizing the public, telling them what was right and wrong.