More than 2,000 children have been separated from their families as their parents are detained and charged with illegally entering the country.