There are only two things that cause bunions: a genetic predisposition and poor fitting footwear.
There is not much you can do about the genetic or hereditary predisposition as you get that from your parents. The research has shown that it is possibly an autosomal dominant trait. This does not mean that you will get a bunion, it just means that you are at a greater risk of getting a bunion. This manifests in the biomechanics of your foot and how your foot functions.
There is something you can do about the footwear. Footwear that is too narrow across the forefoot that pushes over the big toe is the main risk factor for bunions. Combine the tighter shoes with the hereditary risk and they are highly likely to happen. Even if you do not have the genetic predisposition, the wearing of poor fitting shoes is still a risk, but probably not as much as if you are genetically predisposed.
Interestingly, bunions still do occur in those who do not wear shoes, so shoes are not the entire issue. However, in these populations the bunions are never that bad and never get painful. Wearing footwear makes them worse, makes them progress more and makes them painful.