Mine does it when she has licked a lot of her own hair. Sometimes she sicks up the grass and the hair and sometimes it passes through her and gets rid of the hair that way. She also nibbles fresh shoot of grass and gorsebushes (!) and i think that she does this because she likes it. (For those who don't know, when gorsebush shoot are new, they are soft and not at all spikey)
My dog doesn't seem to eat grass when she has a tummy upset though