Some people just get them. I know someone who gets them regularly every 2/3 years, and her father did before her. My uncle gets them every 5 or so years. There was a paper in the European journal of urology that was looking into causes, but I was none the wiser after reading it

Drinking plenty of water so that your urine is straw coloured is the only real proven way of reducing the risk by any substantial amount.
I used to get lots of night sweats - I used to keep a glass of water by the bed to drink in the night - it helped cool me. I still do, but I sleep better now, so sometimes it is still there in the morning

so I drink it in the summer.