What's a urinary tract infection in a baby caused by?

Bacteria from feces. Stool in the diaper gets to or very close to the the urethral opening. Bacteria can then work their way up to the bladder and cause a uti. Baby's thigh movements can cause bacteria or microscopic amounts to soft stool to work their way up to the bladder. Spending some time in a soapy bath, with genitalia submerged can lead to irritation of the urinary opening and facililitation for bacterial entry.