A urinary tract infection happens when bacteria colonize the areas through which urine exits the body. During pregnancy, the chance of getting these infections increases due to changes in the urinary tract and immune system.
As your fetus grows, your uterus expands. This puts pressure on your bladder and ureters (the tubes that connect the kidneys to the bladder). Under pressure, the urinary tract may become blocked and unable to drain urine properly. Pregnancy hormones may also cause the relaxation of smooth muscles, which can result in urine retention.
In this situation, bacteria can readily grow and thrive throughout the urinary tract, causing an infection.