If you're dealing with confinement to a jail cell, or your classroom, or the broom closet, you're stuck there and you can't leave. Confinement means you're being held and you can't move freely.
Confinement doesn't have to be punishment. If you've got a contagious disease, your doctor may recommend confinement to your hospital room. Puppies sometimes prefer confinement in a crate to sleeping in an open room. You may also come across an old-fashioned use of the word confinement, referring to a woman in childbirth, which goes back to when women retired to their rooms to give birth and recuperate. Confinement contains the Latin root finis, "end, limit” — confinement certainly is limiting.