Some dogs are raised eating poop as puppies - they are in a setup where poop eating is easy, and they never stop, so that could be a thing, depending on your dog's background.
Some dogs just like poop.
Some dogs like winter poop (the poopsicle) and will snack on that.
Some dogs eat poop as a snack because they are hungry during the day between meals. Think about how we go to the cupboard, my vet said, when we are feeling a bit hungry, dogs can't. So they pick up a cookie, that just happens to be poop.
Dogs with GI issues especially can have issues if not fed and with that feeling hungry feeling. I think it helps dogs with GI issues to have their daily intake at the highest level it can be without making them sick or overweight, and splitting that up throughout the day if possible. 3 feedings, 2 snacks, that kind of thing.
And yeah, no shock collar. You can condition your dog to a muzzle if you are not able to pick up the poop before he goes out, and he can wear that. Italian Basket Dog Muzzles
This has to be introduced slowly and positively so that muzzle = good stuff. This is fairly easy to do. My 12 yo GI GSD is wearing one now for potties because she is eating the winter poop. She sticks her nose right in and out she goes, comes in and gets a substantial treat - even though she didn't have a choice in not picking the poop up (note - they can still mush it with the muzzle, or lick it, so work on a positive leave it) she's getting the snack.