The practice of locking children in prisons, especially adult prisons, has devastating effects on them. They mix with criminal adults and they tend to follow inappropriate role models. It just makes them worse people.
Article 10 of the International Covenant on Civil and Political Rights states:
Juvenile offenders shall be segregated from adults and be accorded treatment appropriate to their age and legal status. (source)
But even putting them in special child detention centers or so-called “corrective facilities” makes it difficult for these children to get a proper education, to learn appropriate social skills and to receive the special kind of support that only a family can provide. Of course, their families are often part of the problem. Prison guards are no teachers, no matter how well they try (and in many countries, they don’t). Some of these children undoubtedly have to be kept off the streets, but other, non-custodial options must be possible.
However, the fact is that many children are in prison, not because they have committed a crime, but because their parents are in prison (maybe the children were born in prison) or because their parents entered the country illegally. Maybe they did commit some kind of crime, but not one severe enough to have them locked up. They are locked up because their government didn’t provide the funds necessary for adequate guidance and support.