Why am I getting UTI's?

Olivia
I have had 3 UTI's and I can't figure out why. Everyone says it's due to sex but I'm going to be honest. It's always happened during times I haven't had sex! My boyfriend is in the military so he's gone a lot. Sometimes a couples months at a time. And I always get one while he's gone! Besides sex, idk what else can cause it to occur! It's so aggravating. How do I prevent them??