Whether they deserved it or not – I had to have at least two. If only one kid was misbehaving, I had to either let it go without any sort of formal punishment, give them a more serious afterschool detention (which I would then have to explain if their year coordinator (rightly) thought that was too serious, and which were also monitored to look for teachers who were giving too many on the principle that teachers who punished too often were automatically bad teachers), or hope somebody else would do something to deserve it too. Otherwise I had to pick a sacrificial lamb from the last class before lunchtime. I didn’t like doing that but I did it. The alternative was classes that knew minor misbehaviour would be ignored.
Remember, teachers don’t always have free reign. A lot of the time stupid policies imposed from above can be to blame for what they are doing.