The Boys were found lingering next to the forest when the teachers did not find them in the class. After the death of Kang Qiao, the teachers were exceptionally vigilant, the second they found out that the children were missing they went to look for them. The teachers were simply horrified when they found the boys in the forest.
However, when the boys were caught and brought back they were all horrified and frightened. They all told the professors that they had no intention of going in the forest but then suddenly they had an urge to go inside the forest, as if someone was calling for them.
They had no idea how they even appeared in the forest.