Ok, to totally over thinking this but:
some posters are saying that they should be the only people to parent their toddler/be left alone to parent their toddler.
in general I think most people would agree with this.
the problem with this comes when the toddler and parent are in social situations where there are expectations.
for example, sticking with the school theme, the nativity play. Some schools totally ban younger siblings from these because they have experience of a small toddler or multiple small toddlers running around the hall destroying decorations or crying in the middle of someone’s solo etc.
so sure, parents should be able to parent their toddler as they please - but if your two year old is singing loudly out of tune during the quiet bit in the nativity you are going to get some very very pointed looks and quite possibly a lot of comments afterwards.
in the same way, in this situation you’ve been pulled in to have a conversation with the teacher about your sons behaviour. This is presumably at pick up time.
the teacher(s) running the afterschool club will not expect toddlers to randomly appear and if a toddler did randomly appear they would quite likely have words with your class teacher.
so while yes you should be able to parent your toddler as you choose there’s also an expectation on the teacher here from the school that they not disrupt the activities of others (and it would be considered at least partially the teachers problem).
so I suspect the teacher got involved because they could see a potential problem and wanted to make sure it didn’t happen.
again, within the context of school the teacher will be expected to try to make sure her class is behaving while walking down the corridors/in assembly/on the way to swimming/on a school trip etc and she is on alert at all times for children trying to be somewhere that they shouldn’t.
not all teachers have children and not all teachers have experience with two year olds.
telling your toddler “no” is completely understandable from a teacher perspective.