The school's cake, pizza etc won't be made to the same recipes as the cake, pizza etc one might put in a lunchbox.
Usually when a school bans things, it's a last resort after appeals to common sense have failed. IIRC one of the problems at this school is squash and flavoured water - which is sticky when spilt, unlike plain still water. If you're banning all chocolate it's not because of a weekly two-finger KitKat but daily 100g Dairy Milk (later smeared on Maths book). If you say no sweets it's in the hope that Jack in Year Two will get something other than a grab bag of Haribo and a Mars Bar.
If you ask MNers what a packed lunchbox should look like, there's a conversation about wraps v sliced bread, about ham v cheese, about remembering to slice grapes for younger children, about pasta salad and bento boxes and whether there's too much salt in hummus. It isn't these lunches that are being targeted.
So yes maybe it would be better if the school said "cake: only if less than 15% refined sugar" or "cold pizza: only if wholewheat crust and contains one of 5 a day" which would mirror their own standards, but (1) who would adhere to that and (2) how could they check anyway?