In real life
One child with measles in a classroom where nobody is vaccinated could infect 12 to 18 others. In a school where 95% of children have had two doses of measles vaccine, that same child might infect nobody. The handful of unvaccinated children are protected too, because the virus simply can't find a path to reach them.