The town where I live has some of the most stringent health agents I’ve ever known; and when my son was in elementary school, the PTO would put on a pasta feast fundraiser for the school community. The year I was on the PTO board was the year new regulations were enforced - the PTO could hire the cafeteria kitchen *but not the staff* and produce the meal but under the watchful eye of the health agent to ensure that all regulations were followed to the letter. There had to be someone ServSafe Certified in the kitchen and because we couldn’t hire the regular cafeteria staff, it had to be a parent. It was the silliest thing ever. They did the same thing to the church too. So both the PTO and the church had to spend money to send parents and parishioners to the ServSafe class just to be able to do bake sales, dinners - any time food was served. The answer from the Health Department was because the general public (because the school community and the church community were part of the general public) was being served food and it was their job to make sure it was prepared and served according to the regulations.
The church still has ServSafe people in charge of each function but at least now the school system allows the Food Services department to price things so the PTOs can make a little money - the Food Services staff makes and sells the meals so the health department is happy. But kids cannot bring treats to school that are home made; everything has to come from a package.
If a venue says that food brought in has to come from a licensed facility, it is because their insurance policy won’t allow them to serve food that isn’t prepared on the premises or prepared in a licensed kitchen; whether money changed hands or not isn’t the issue, whether it is a gift or not doesn’t matter. I’ve had more than a few people call at the last minute because they had a family member who was going to make the cake and then find out it’s not allowed. It’s sad, because sometimes it’s a family recipe, or the memory of the treasured relative who made the cake that is important.