@Simpleton
Generally speaking, kids in Japanese high school stay in their class for the most of the day (except for certain classes like labs) and teachers go to them. That's why even in a grade level, the kids in the same class (home room class) form much tighter bonds. And the kids tend to hang around in their class with their home room classmates much more, rather than roam around the school and into other "territories." This stratification is even more pronounced between grade levels, like 1st graders generally won't go to where 2nd grader classes are, and will almost always stay away from 3rd grader classrooms. Even if they visit, they'll most likely stay at the door to the class without entering and ask for their friend to come out. Also, since the classes in a grade level are all bunched up, the usual way to a lab like in this case isn't necessarily the shortest one, IF it cuts through other grade level's floor or classrooms. They might have to go to a common level to walk across and then up to the lab, etc.
It's not strictly followed or enforced, and a group of rowdy kids, especially boys, could decide to cut through other grade level's floor to get to the lab before the bell rings. And that's what's shown here.