If your dog is eating grass or weeds the dog likely has an upset stomach and is eating the grass or weeds to help it throw up and get rid of the stomach ache.
It can also mean that they're just curious about the grass or weeds are just eating it because they like it and as long as the weed isn't poisonous or the grass or weeds do not contain poisons or pesticides then it's perfectly safe for the dog to eat grass and weeds.
I had a dog that would always throw up soon after eating grass or weeds so it was due to an upset stomach for my dog.