The key to prevent urinary tract infection is hygiene - even if you don't shower daily, you should at least change your undergarment every day.
Females get urinary tract infection much more frequently than males because anatomically their urinary tract is shorter and the urethra opening is closer to the anus. But men can get UTI too so be careful!