Dogs are naturally omnivores and so eat both plant and animal. Ancestors of our modern day canines ate fruits and berries in the wild. Today’s domesticated ubanites have easier access to lawns and grasses. Dogs are also opportunistic and if an alternative “food source” is available may opt to take advantage of it. Prior to domestication, dogs would eat other animals as well as the contents of their stomachs, often containing botanical material. What we see as a pristine botanical garden, Fido may recognize as a buffet. More often than not we are simply witnessing instinctual behavior.
Alternatively, your dog may be experiencing gastric upset. It is unclear why dogs eat grass to ease their discomfort. Grass contains essential nutrients that the dog may crave and there is little harm in eating it unless it’s been treated with pesticides and the like. If eating grass is atypical for your dog, consider consulting with the vet to see if there is an underlying issue.