Detention is one of the most common punishments in schools in the United States, the United Kingdom, Ireland, Singapore, Canada, Australia, South Africa and some other countries. It requires a student to report to a designated area of the school during a specified time on a school day (typically either recess or after school) and remain there for a specified period of time, but also may require a student to report to that part of school at a certain time on a non-school day, e.g. "Saturday detention" at some US, UK, and Irish schools (especially for serious offenses not quite serious enough for suspension).
In the grounded videos
Detention is commonly caused by characters getting their answers wrong or for some random stupid reasons. Some depict characters farting in detention, which either gets them suspended or expelled.