This is not a simple issue and is complex and multiple factors are involved.
Poor fitting and tighter shoes are widely believed to be the problem, but not all of those who wear tighter fitting shoes develop bunions, so that is not the whole reason. Bunions are even seen in those who do not do not wear shoes, so shoes can not be blamed in those cases. However, they are not as common in those who wear shoes. This means that poor shoes are only part of the problem, and not necessarily the whole problem. Shoes may play a role in making the bunion progress more quickly and may play a role in making them painful.
Hereditary factors play a role, in that if your parents have them, then you are more likely to have them. But research has shown that while there are hereditary factors involved and if you have those hereditary factors then that does not necessarily mean that you will develop them.
It could be that the actual cause involves other factors as well. At the moment hereditary and shoe factors combine to increase the risk of developing a bunion, but that does not mean that it is inevitable.
The next challenge is can those factors be changed or altered to prevent or treat bunions? Firstly, you can not change your parents, so hereditary factors can not be changed. They should, however, increase your awareness that you are at an increased risk of developing a bunion. For example, you may want to pay extra special attention to the fitting of the shoes to help prevent them from developing.
The other main factor is the shoe and you can do something about them. The shoes need to fit the foot. They should not be pushing the big toe over to create a bunion. This is not a short term solution and is something that you need to keep up over the long term or problems will develop.
Like so many health issues preventing bunions is knowing what increases the risk for the problem and reducing those risk factors where possible.