Some people believe that dogs eat strange things to stimulate vomiting or diarrhea, but this is undermined by the fact that most dogs do not act ill before eating grass.
Besides, most dogs that eat grass don't vomit at all.
In fact, some people eat weeds for that very reason.