Shame is the emotion felt when a person realises that the behaviour they are engaged in is forbidden. Shame is a learned response to the environmental rules and regulations in which the individual operates. What is permitted in one environment might not be allowed in another. It is a way of following the rules of the tribe.
Where a child unknowingly transgresses a tribal (family) rule then punishment is not appropriate but an explanation or what they have done might be. No-one should be made to feel they are bad because of behaviour that they were unaware was not appropriate.
Shame is a feeling adults may feel because of behaviours they engaged in which may have been risky or illegal or in which they were forced to participate.
Parents may feel shame because of the behaviour of their child in public and think that they are useless at parenting.