Most are "ideopathic." In other words, we just don't know why they occur.
There are some environmental factors which may play a part,sometimes it's metabolic, stuff like gout etc.
Here's some stuff about prevention, apologies, not sure how robust the info is...
It is important to drink plenty of fluid, especially in the summer months or a warm climate (urine output should be kept at > 3 litres per 24 hours).
Other prevention measures are directed towards the particular type of urinary tract stone:
calcium stones - reduce calcium intake and avoid vitamin D supplements
oxalate stones - reduce oxalate intake - foods with high oxalate content include chocolate, tea, nuts, beans, spinach, beetroot; reduce intake of citrus fruits (vitamin C)
cystine stones - high fluid intake, alkalinization of urine, D-penicillamine acts as a chelating agent
triple phosphate stones - antibiotics
uric acid stones - allopurinol, urinary alkalinization
Source:
GP Notebook