Coco used to do this and used to eat her own poo as well as any other poo she came across when out on walks
The only way is to be very vigilant about clearing up any poo you can see asap. If I saw her doing it, I used to say a very firm "No" and distract her with a tasty treat
She seems to have grown out of it pretty much now and will stop if I tell her no - unless it is horse or sheep poo in which case she will just grab a big mouthful and run off