There are many reasons dogs throw up. Sometimes they eat too much grass and they vomit, other times their stomachs are just a bit irritated. Vomiting can also be a sign of serious illnesses.
Dogs throw up from emotional exitement, from nausea (feeling sick) and sometimes because they are bored and have learned to do this since mothers throw up to feed their pups.
The same reasons that humans throw up-they don't feel well. It could be that they ate something that was spoiled and it made them sick. If they are throwing up all the time you might want to take it to the vet to rule out any disease.
The reason dogs eat grass is to clean out their system. It is an instinked that is built in. If your dog is eating grass all the time this may indicate a food that does not always agree with the animal. change the animals diet a bit.