Dogs vomit for the same reasons that humans vomit. To get rid of unwanted or indigestible substances from the gut. Your dog may have eaten something that his stomach doesn’t agree with, which has caused vomiting, such as a change in diet causing an intolerance or a foreign body (a small toy).
Dogs can suffer from travel sickness and heatstroke. Sometimes vomiting can be a sign of a more serious medical condition such as a stomach ulcer, intestinal parasites, viral infections. If you suspect the vomiting is due to something more serious you should take your dog to the vet.