This is caused by the endocrine/immune responders to the infections, this is the HPG axis response (hypothalamus pituitary Gonadal). The HP stimulates the gonads to produce hormones that act as resistance to the infections.
There is another response which is the HPA axis (hypothalamus/Pituitary/Adrenal) response. Where the HP stimulates the adrenals for adrenal responders.