Hi xxx ! Thank you for posting your questions here.
I would say that yes all the conditions that you mentioned :
Masturbation,
dehydration, after sex , your period,are the reason of having recurrent Urinary Trac infection .
The most often bacteria is
E.Coli , which is a normal part of the intestine , outside anus.When this bacteria goes to your
urinary tract may cause infection.So every condition that give chance to this bacteria to go to urinary tract will cause this.
Follow these advice to prevent the infection :
keep clean the genital area
drink a lot of water .
don't keep the urine , empty your bladder frequently
Urine before and after sex and clean the genital area before any sexual touchings.
Drink cranberry juice
switch another method for birth control , condoms sometimes can cause irritation.
Wish these help.