For perspective: I come from a country where "cafeteria" food at school is good and affordable (most is less than the equivalent of 5-10 USD max and it's not slop, it's actual food), but it's not an obligation for everyone since it's up to the student if they want to buy something or bring their own lunch.
The "cafeteria" in my school isn't a typical American one, rather it's closer to a canteen where they sell food you can purchase from cup noodles, fried stuff, sandwiches, baked goods, etc. also appliances like a kettle or microwave are available in the dining hall for students to heat up left overs if they wanted.
The thing I tend to notice from American schools (according to US movies, there's bias whether it's true or false) is that they tend to depict kids always heading for the cafeteria for recess or lunch picking up whats available instead of bringing their own food from home (left overs from dinner), why is that the case?
Sometimes bringing your own food is due to cross-contamination in cafeteria foods, especially if a kid is allergic to stuff. I was below poverty and still had to bring my own food due to celiac disease.