They find it feels good to touch themselves in this way and continue to do so. Most children do this as a comfort measure much like a pacifier is for infants. This causes pain or itching, so the child may scratch the area and this should be distinguished from masturbation. Once masturbation begins, it seldom stops completely. However, by age five or six, most children learn some discretion and masturbate only in private.
Masturbation becomes almost universal at puberty with normal surges in hormones and sexual drive.
Accept the fact that she has learned it and enjoys it. Therefore, a reasonable goal is to control where it occurs. Perhaps limiting it to the bathroom or bedroom. Tell your child it's okay, but it is a private thing that should only be done in her bedroom. Don't ignore it completely, or she may think it is okay to do it freely in any setting leading to criticism by adults and chiding by other children.