This is a great anecdote to describe a formal approach which is called
positive discipline.
We assume as adults that children who do things that are not what we want or against our instructions need “discipline” in order to learn they should have made a better choice.
This fails on the most basic point. Young children are, in most cases, not making a conscious choice at all in these cases. They are not thinking in their brains, the same way we adults imagine a conscious decision making process occurs, weighing the concequences and choosing a certain path. They are not deciding to be bad because it is easier/more fun/worth it at that age.
Positive discipline is not actually discipline at all. It is fundamentally a realization that children make “mistakes” because they weren’t actually capable of doing what was asked of them.
The essence of positive discipline is the search for the underlying reason a child is not capable of following your direction at that point in time / for the task at hand.
Barring an exceptional case, (younger in particular) children are straight up desperate for attention and affection of their parents.
Sometimes this is the hardest thing in the world, as a fully functioning adult, when your child is doing something [annoying/destructive/insulting/dangerous/disgusting] after the n-th time you’ve told them not to. Adults respond to punishment / negative reinforcement very differently than [young] children.
In particular keep in mind this is primarily a learning experience for a child to develop coping skills and the ability to regulate their emotions. The skills don’t develop very well from a basis of fear of reprisal in my opinion.
I’m not always able to practice positive discipline with my kids, but I can’t count the number of occasions where I’ve pulled out that tool in response to some stressful situation and watched the sheer relief/release on my kid’s face when they manage to actually communicate outloud to someone that will listen that thing that had them so upset or feeling sad/mad/lousy.