Diane, your daughter has gone through a lot in her first three years and it sounds like you've done everything possible to support her through it. It's great that you breastfed your daughter for a year and gave her the best nutrition and immune protection, as well as physical closeness and bonding with you. You also help her by recognizing when she is tired or stressed, and allowing her to find ways to calm herself.
All children experience stresses in the course of their normal development and daily lives—separating from their parents, falling asleep on their own, and dealing with fatigue and frustration. It's common for children to develop habits to comfort themselves in times of stress, e.g., sucking a pacifier or their thumb, twirling their hair, or cuddling a blanket or stuffed animal. When your daughter plays with her nipple, she is also comforting herself and relieving stress. Since the nipple (just like the mouth, belly button, and genitals) has a rich supply of nerves, touching it gives children pleasurable and calming feelings.
Many parents are embarrassed when they observe their children touching their breasts or genitals. Think about how your reactions may be affected by your own parents' attitudes toward masturbation and their reactions to you as a child. And think carefully about the messages you want to give your daughter about her body, her feelings, and her sexuality.
Our current understanding of child development shows that it's normal and healthy for children to learn about their bodies and experience pleasurable feelings. Especially since your daughter has experienced physical pain with her surgeries, having the chance to experience physical pleasure can be particularly helpful for her. You can help your daughter develop a healthy identity and sexuality by maintaining a calm and accepting attitude toward her touching herself, and avoiding any reaction that makes her feel ashamed. Calmly help your daughter understand our society's rules about touching herself—that it's natural and private, something she can do in her bedroom.
As your doctor said, and you've also observed, your daughter is likely to do this less and less over time as she matures and finds other ways to relieve stress and comfort herself. If she still has this habit when she begins preschool, talk with her teacher about it and make sure you both have the same positive, supportive approach to your daughter.
Our parenting advice is given as suggestions only. We recommend you also consult your healthcare provider, and urge you to contact them immediately if your question is urgent or about a medical condition.