Punishment, whether it is incarceration, the seizing of assets, the suspension of driving privileges or just good old fashioned grounding for a lippy teen, is justified by the crime or indiscretion to which it is a response.
For a child, if what they were doing could cause harm, it is always acceptable to discipline them. If the child was disobeying explicit instructions, that is also acceptable - or else they may disobey and get hurt.