One reason could be that the boy was being disrespectful. For example, if he was using bad language in the friend's house, the mother might spank him as a form of punishment.
Maybe the boy was caught being overly rough with his friend. In a family where physical aggression is not tolerated, the mother would spank the boy to show that such behavior is unacceptable. She might be trying to protect her own child and teach the visiting boy proper behavior.
In some stories, the boy might have been causing trouble in the neighborhood where the girl lives. For instance, he could have been vandalizing property or being a nuisance. If the girl's mother caught him in the act, she might have spanked him out of frustration and a desire to stop his bad behavior right away. But this kind of physical punishment is now considered inappropriate in many places, and alternative methods of correction are preferred.
One reason could be to show authority. A friend's mother might feel the need to discipline another child if they are causing trouble in her home. Another reason could be a lack of proper communication. Maybe she didn't know how else to get the child to stop misbehaving. For example, if the kids were being too rowdy and not listening to her requests.
I don't think such stories are common at all. In modern society, spanking is not really an acceptable form of discipline in most cases. However, if we look at it from a story - telling perspective, it could show the consequences of bad behavior. Say the boy was caught stealing cookies in the kitchen of his friend's house, and the mother spanked him as a strict warning not to do it again.
Perhaps the boy used bad language in front of the friend's mom or the family. In some families, using inappropriate words is considered a serious offense and might lead to such a punishment. Also, if he was causing a general ruckus and disturbing the peace in the household, the friend's mom could have spanked him as a form of immediate discipline.
One possible reason could be that the boy misbehaved towards the girl. For example, if he bullied her at school or in the neighborhood, the mother might feel the need to discipline him. Another reason could be that the boy did something that violated the family's rules while in their home, like breaking a precious item or being disrespectful.
One reason could be to show the idea of discipline. In some fictional settings, it might be used to teach the boy a lesson about right and wrong.
The new mother may be under a great deal of stress. Taking care of a new baby is extremely challenging, and if she has other children as well, a misbehaving child could push her to her limits. She might think that spanking is a quick way to get the child to stop the unwanted behavior, like if the child is constantly fighting with siblings or making a mess right after she has just cleaned up. But again, there are better, non - violent ways to handle such situations, like teaching the child about consequences through positive communication.
One possible reason could be that the child broke a very important rule, like cheating on a test in the case of a teacher, or lying repeatedly to the mother. However, this still doesn't justify spanking.
It could be written to explore themes of discipline in a very extreme way. Maybe the author wants to show the negative consequences of inappropriate or excessive discipline. But this is a very controversial way to do it.
Perhaps she was in a very bad mood at that time and took out her frustration on you. However, this is no excuse for her inappropriate behavior. It's important to note that she has no right to spank you regardless of the situation.