UTI and sex

Aren't the urethra and vagina two different openings? Why is it not okay to have intercourse while you have uti?