If urine is sterile, why do people warn that refraining from urination too long will cause a bladder infection or urinary tract infection?
Urine is sterile when in the bladder.
You have bacteria in the urethra (which goes from bladder to outside). When urinating, you usually wash out the patogens in the urethra, but some can still remain there. Then, if you don't urinate, bacteria can go up in the bladder and gives you patologies, like cystitis, or other type of infections. ((little off-topic: this is the main reason why females have more often than men cystitis. Female urethra is shorter than the male's one, and so bacteria can go up more easily)))
This can bring also the bateria up in the ureter (which goes from bladder to kidney) if you refraining from urination too long continuously, causing kidney infections.