The real reason is that the school doesn’t want free market competition for the snacks. It’s like taxi companies trying to prevent Uber from moving in.
I sold snacks all the way through high school. I needed the money. It was easy to turn $5 worth of candy into $25. You had to be smart enough to fly under the radar. If you’ve ever seen Breaking Bad, when Walter White sees a guy buying ALL of his meth supplies all at once in one store, and WW gives him advice on how to not attract attention, then you’ll know the general vibe of successfully selling snacks in high school.
I remember in grade school way back when, a student who’s parents owned a convenience store would bring in bags of penny candy (back then) Jolly Ranchers, Jawbreakers, licorice ect. Into the classroom. He probably got them in bulk from vendors for much less than 1 cent and sold them to us for 5 cents a piece. The teacher never batted an eye, or was so oblivious it didn’t register. This has gone on forever, unfortunately also in the case of drugs. There are entrepreneurs in every social setting where a need or opportunity exists.