Kids that age are not known for follow-through or self-restraint, or for their understanding of concepts "nice" or "mean," so it's useless to expect that. It will come very gradually over the next several years.
As others have suggested, distract he with something else so you don't have to say "NO" all the time. And when you do say no, be prepared to follow through at the same time by removing her hand from your hair, or taking the forbidden object from her hand and replacing it with something acceptable.
Too much negativity will work against you as she gets older. Offering desirable alternatives will keep her less frustrated as she gets older, and will help keep your family life happier.