Detention is a word for confinement or imprisonment, usually for a short time. It's also a punishment where children must stay after school.
If you're in detention, you probably did something wrong: you're being confined against your will. The police hold people in detention, and so do military forces. Usually, detention is a short period of confinement, like if someone is arrested and then released. Also, the word is commonly used for an after-school punishment for children who have to stay in detention instead of going home. One thing is true of both kinds of detention: no one wants to be there.