Lots of confusion out there around the difference between consequences and punishment. Unfortunately, you don't want to mix them up as they are VERY different in relational terms.
Kids need to experience consequences but they do not need you (their attachment figure) to strategically punish them. In fact, doing so can tarnish their trust in you or in themselves.
Consequences are the disappointing and sometimes painful results of an action. Our children need us to allow them to experience these things in increasing doses as they age so they can connect the dots between their choices and the outcomes of the choices.
Punishments are intentional pain inflicted in an attempt to control a child's behavior. When we use punishment to try to motivate behavior we simultaneously dimish the fullness of our role as a safe haven for our children.
The less you are focused on controlling your child (either by rescuing them from the pain of consequences or by inflicting punishments) and the more you are focused on facilitating their learning and trusting their process, the more secure your relationship and therefore the more internally secure your child will develop. Which is the very thing that leads to good decisions and clear paths into healthy relationships.