Homemade treats are allowed at our elementary school. Our pre-school is nut-free, so no homemade treats there. I think they always had the no homemade treats rule (due to health/food safety issues), but now they're really strict about you can't bring anything from the grocery store bakeries because of "made on shared equipment" warnings. All of this is FINE by me as my child who goes there has a peanut allergy. There are plenty of "safe" foods out there. Nuts aren't too hard to avoid.
When my little one goes to elementary, I'll just make treats for him on party days. He can have cookies, cake, etc., but made homemade BY ME. I would never trust anyone else's cooking/baking for him. A lot of people think that if it doesn't have actual peanuts in it, it's safe. They don't pay attention to the "may contain", "made on shared equipment", etc. warnings like the parents of food allergic children do. AND, who knows what kind of cross-contamination may be in their kitchen -- made PB&J for their kid earlier, didn't wipe the counter down good enough, etc.
I have no problem if homemade treats will be allowed in his class (he'll be old enough to know that he can't have it -- he does great dealing with it now at 3 -- I let his older brother have things he can't). But, I'm pretty sure the no homemade treats rule that started in certain states/school systems had to do with health issues (as someone else pointed out, foodborne illnesses, etc.), not allergies. I'll be the first to admit, I NEVER buy from bake sales because I have no idea of some stranger's cleanliness practices.