Your own bacteria. Urinary tract infections (UTI) come from bacteria already living on your perineal ("bottom") area. These "bad" bacteria that cause UTI are usually kept in check by other "good" bacteria living in the same area. Reasons women get infections are multifactorial (multiple reasons) including sexual activity, state of immune system, anatomy, bladder function, genetic predisposition, possibly diet, etc.
Bacteria + host. Utis are caused by bacteria, most commonly e. Coli. For an infection to take hold, bacteria has to make its way into the bladder while overcoming normal host defenses. Women tend to have more utis than men because the urethra is short, and closer to bacteria of the perineum. Sex and use of spermicides can increase the risk. After menopause, decreased vaginal estrogen can lead to infections.