80% of kidney stones are calcium oxalates.
(https://www.stonedisease.org/calcium-oxalate-kidney-stones)
They arise when the body doesn't have enough liquid(water) to solve the salts (most calcium) in the urine.
Otherwise if you consume too much stuff which contains oxalates, like spinach, cocoa, chocolate, beetroot and black or green tea.
Than the salts can't be solved and gets solid in this way:
Urine with a lower pH-value than 5,5 (normal 6) will favore this reaction.
Bedrest will also increase the calcium concentartion which effects the same.
To prevent kidney stones you have to drink a lot of water, make sport and eat balanced healty food.