The main reason why dogs graze on grass is to induce vomiting when they have stomach problems. Other reasons include to aid digestion, treating intestinal worms or as a result of some nutritional deficiency.
If you think about what a dog would eat if it were wild, grass sort of makes sense. If a dog were to eat an animal, say a deer, the stomach would contain grass. Dogs are sort of scavengers, maybe its instinctive.
This happened to my dog last nite. I put the flea preventative, Vectra, on her and she had a reaction. She started wrenching and to go outside. outside, she tried to eat lots of grass. I called the vet. He said to wash the flea stuff off with Dawn liquid. I think she was trying to settle her stomach.