EYP can happen when eggs are poor quality and a soft shell egg gets stuck and collapses. Yolk quickly invites bacteria to colonize the reproductive tract, and untreated, it will become a chronic infection.
Or a hen may be laying internally, eggs accumulate and bacteria grows. No one knows why this happens.
If you suspect an egg has broken inside a hen, she needs to be treated for the obstruction and given an antibiotic for infection.
EYP isn't contagious, but if there is a buildup of poop in coop and run, bacteria may become heavy and if a hen is trying to lie about in the dirt and feces, bacteria can find its way into her cloaca and then march up her oviduct and infection will be triggered.