Thank you for writing. I assure you: You are doing nothing wrong. It has nothing to do with breast feeding.
I hope the pediatrician checked for pin worms. Sometimes children rub their genitals because they itch. If she is medically fine, then your doctor is probably correct that she is masturbating because it feels good.
Infant masturbation is more common than you may know. It is harmless. It does not indicate that she will be sexually deviant when she is older. She simply finds it comforting, much like another child might find using a pacifier or sucking their thumb or dragging a favorite blanket around all day.
Boys do it as much as girls but parents don’t tend to be as alarmed as the parents of girls, perhaps because male masturbation is more accepted.
It is not helpful to punish a child for doing this. She is not doing anything “wrong”. She has found that touching her genitals feels good. This is a natural part of exploring her own body and discovering what gives her comfort and pleasure. Babies often use masturbation as a way to calm themselves or relieve boredom. It is only a “problem” if it is so intense that she won’t be comforted any other way or she hurts herself.
This behavior generally peaks at about 2 1/2 years old and lessens after that. Most children give it up on their own as they find other ways to manage tension or distress. If it goes beyond age 3, it is possible to then talk to the child about when and where it is okay to do it. Until then, it is usually fine to ignore it while at the same time making sure that the baby is getting enough soothing and attention from her parents.
I suggest that you talk to the nursery school staff and see if they see it as a problem. It may be that they are quite accustomed to dealing with little ones who self-stimulate in this way. They may also have some thoughts about whether and how you could help your little one find another way to manage her need for comfort.
I wish you well.