Hello & Welcome to Just Answers.
All babies and children learn to do what feels good to them - whether thats twirling, playing with their toes, sucking on fingers & thumbs, and masturbating. Some, like your daughter, hone in on masturbating as a pleasurable experience early on and are unlikely to forget it. She'll eventually learn the social norms of when and where she can enjoy that activity, but right now, it's highly unlikely. You'll need to keep distracting her till she can understand the where & when factor.
You can come up with a statement like, "Honey, that's for private time" when she gets a little older, and re-direct her to her room. Not in a 'time out' way, but the same way you would for her to change her clothes.
It can be embarrassing for the parents, but let me assure you, this isn't isolated. There are many children who spend their 3's & 4's with their hands in their pants. It can be a little harder for parents of girls than boys. The only problem is if you suspect that she's being stimulated by another person, and is following their lead. But at her age, this activity is very normal and isn't seen as a sign of suspicious activity.
My best to you.
If you would, please fill out the feedback form after accepting. I appreciate this opportunity to help you out today. If I can be of further service to you, just put "for Anna" in the front of your new question, and I'll be the one to answer it.