MAIDUGURI, Nigeria—In a forest of thorn trees somewhere far outside this city, the Boko Haram insurgency ran a boot camp for about 100 boys. Children as young as 5 years old learned to handle assault rifles and march through the woods in flip-flops. Their teacher was only 15.

“I was terrified if I didn’t do it, they would kill me,” said Idriss, the teenage instructor, in an interview. He said he was kidnapped by the militants in 2014 but has since escaped.

...