At 3, that's appropriate.
Younger than that, no. A 2-year-old can be expected to act out and there's not a lot that can be done about it. Physical punishment isn't generally effective because the whole cause-and-effect thing isn't a firm concept in their minds yet. Yet I've seen people beat a 2-year-old to try to keep them quiet. It didn't work and I wouldn't expect it to. A good parent simply doesn't bring a 2-year-old to a lengthy, formal, sit-there-and-be-quiet event.
The OP specified "under 5" and that's a range where the developmental milestones come fast and hard. A 5-year-old should be able to sit quietly for a while but I wouldn't expect them to endure, say, a full hour+ of a church service without getting restless. That's why my last church had a kids church, internally. The little ones stayed in the main sanctuary for the initial greeting, song, and prayer. Then they all left to go to a different room where they had their own service that was more, shall we say, relaxed.
Personally, I'd say anyone with 5-year-olds who brings them to something formal where they must keep quiet for a long period is either:
In the former case, when the kid acts up the excellent parent will remove the problem from the venue. In the latter case, that won't happen and I believe it's the parent who lacks discipline, not the kid.
- an excellent parent who has taught their children how to behave in public, or
- a parent who doesn't care.
We're gonna have to agree to disagree on that. And I disagree pretty strongly. And there is a huge difference in a "beating" and a swat on the bottom. And I can tell you from personal experience that a two year old can be taught to behave. And my kids went to events at two years old and behaved. If an event is going to go on much longer than an hour or two, sure, take them out and give them a break.
And those kids turned out to be wonderful young adults. No emotional scars. Well above their peers.