what is pyometra in dogs and why it occurs

Pyometra happens to be a secondary infection in female unspyed dogs

the progesteron hormone remains elevated even after two months of their heat cycle ends.  

pyometra is a bacterial infection occurs several weeks after a dog's heat cycle. 

the hormone causes the uterus lining to be thickened as it prepares for pregnancy 

the cervix relaxes during the second week of estrus (heat) allowing the bacteria to enter the uterus.

the lining of uterus for years  enhances the  chances of infection

lack of proper hygiene during heat cycle could cause this to occur .