A warning is to make someone aware of impending danger, or to caution someone against unwise or unacceptable behaviour.
In a situation where spanking is a possible, legally and socially accepted form of punishment, a person may warn their charge (such as a parent or teacher warning a child) that committing (or often, repeating) a certain offense they seem to be about to do will result in a spanking. They may also detail the kind of spanking, such as what implement will be used and perhaps whether it will be on the bare bottom, in front of witnesses or otherwise intensified.
Such a warning, stated in no-nonsense words and tone, is psychologically important for both persons. If the warning is respected, nothing more will happen. But if the warning is ignored, and the said punishment follows, it appears fair and just because of the warning — even when it is severe for the offense. The offender has obviously deliberately decided to disobey in full knowledge of the consequences this was said to have. The offender is therefore fully guilty not only of the offense but also of not taking the warning seriously, and their punishment is well-deserved. The authority figure, in turn, is psychologically forced through the spoken out warning to make their words true and administer the punishment because if they don't, future warnings will be taken even less seriously.