First, it is gross but not necessarily dangerous. Puppies will eat their own or other dogs poop but the behavior tends to fade away at about 9 months old.
However, I would discourage your dog from eating a strange dog's poop because you don't know the health of the other dog, but it doesn't mean your dog is in immediate danger. In addition, your dog should not under any circumstance eat the poop of another animal.
More info on why an adult dog would eat poop (as found on http://akc.org):
If your adult dog starts to dine on dung, you should consult with your vet to rule out such health problems as:
parasites
diets deficient in nutrients and calories
malabsorption syndromes
diabetes, Cushing's, thyroid disease, and other conditions that might cause an increase in appetite
drugs, such as steroids
In many cases, dogs start to eat their own poop because of some kind of environmental stress or behavioral triggers, including:
Isolation: Studies have shown that dogs who are kept alone in kennels or basements are more likely to eat poop than those dogs who live close to their people.
Restrictive confinement: Spending too much time confined in a small spaces can cause the problem. It's not unusual to see coprophagia in dogs rescued from crowded shelters.
Anxiety: often a result of a person using punishment or harsh methods during housetraining. According to this theory, dogs may eliminate and then eat their own poop to get rid of the evidence, but then they are punished more. It becomes a vicious cycle.
Attention-seeking: Dogs eat their own poop to get a reaction from their humans, which they inevitably will. So if you see your dog doing this, don't overreact.
Inappropriate association with real food: Dogs who are fed in close proximity to their feces may make a connection between the odors of food and those of poop and will be unable to tell the difference.
Scenting it on their mothers: Lindsay writes that in some cases, puppies will get confused by sniffing fecal odors on their mother's breath after she has cleaned them. Also, sometimes mothers may regurgitate food that is mixed with puppy fecal matter. He calls this an "appetitive inoculation," which may set a puppy up to develop this bad habit.
Living with a sick or elderly dog: Sometimes a healthy dog will consume stools from a weaker canine member of the household, especially in cases of fecal incontinence. Scientists hypothesize that this may be related to the instinct to protect the pack from predators.
How to stop this behavior:
Veterinarians and dog owners have seen improvements with a handful of strategies, including:
Vitamin supplementation: There's been a long-standing theory that dogs eat feces because they are missing something in their diets. Vitamin-B deficiency, in particular, has been a prime suspect, and studies have backed this up. In 1981, scientists showed fecal microbial activity synthesized thiamine, a B-vitamin. Other research ... (more)