From the students' point of view:
If they are naughty students, I think these students can be influenced. Students like this can easily get along with teachers who care for them like you.
And if they are ordinary students, these students need teachers' attention and communication more.
If you are an obedient student, you should communicate with them more and understand their psychology to keep their good performance.
In fact, I think students need teachers to treat them fairly, care more and communicate more. As long as they think the teacher has good intentions and actually know them well, they will cooperate with the teacher very much. I am such a student, and so are most of the students I meet.
For the above situation, I suggest asking them why they were punished by the teacher in a caring tone. When they have finished their explanation, don't criticize them, but politely say that it is best to talk to the teacher who punished them and let them return to class.
I hope you can win the love of students.