It's really just a time filler to cover the gap between when classes end and a school game begins. Growing up in the US I think we had ~1 or 2 per year from ~8th-12th grade. They were also generally fairly short as in 10-15 minutes with I think one lasting 45 when the other team was late.
PS: Most games did not take place during the school day, but I think they scheduled a few that with a small overlap if a team would otherwise get home really late during a week night. I think there much more common in low density areas for this reason.
Edit: Though like all such traditions it's been morphing for a while. With some schools holding them before big events and or in the middle of the day.
I couldn't imagine my school in Scotland doing anything similar (and we were a very sporty school, with compulsory attendance at a lot of inter-school games, which I mostly sneaked away from).
Nationalism is IMO deeper than that. To use a EU example, many people in Greece complain about countries that are giving them money. “How dare they attach strings when handing us money!!!” That’s nationalist in ways I have trouble understanding.