The judges sentencing these girls to detention aren't necessarily another bad guy in their stories.
judges don't want to return girls to abusive homes or to a ruthless pimp, so they detain the girls as a way to keep them safe.