Like you have noted, coprophagia (the technical term for feces-eating) can, like dirt eating, be a response to a dietary need (often stuff like missing enzymes and the like in their diet). If the dog eats a dry-food only diet, they will be missing certain things that might make them more prone to seeking out poop as a way of filling that need for digestive enzymes.
It can also be a stress response - dogs who are anxious or stressed have a tendency to eat poop more often, as do dogs who have been excessively punished for making messes in the house, for example.
Attention seeking can also account for it as well - negative attention is still attention after all! I can also just be an oral fixation, which usually can be solved with giving the dog something better to chew on than poop.
There are a few things you can do to stop the behaviour. If you know the dog is eating its own poop, there are products you can add to its food to make the poop taste undesirable. You can also work with your dog to teach it a "leave it" command, but if the dog is outside without you present, this will be less effective, as then you won't be around to stop the dog from eating it. There are also things (such as bitter apple and bitter orange spray) that you can put on the poop itself to make it less interesting to the dog.
In general, the best suggestions are to keep the yard poop-free, or to train your dog to leave things alone on command.