There are a few reasons for a bunion to form.
Genetics. In many cases it is a genetic tendency passed down from generation to generation, more commonly in women. Theory is that there are biomechanical flaws in the foot altering the foot function, leading to over pronation and resulting in abnormal stresses while walking or standing. Over time, this causes damage and stretch to the ligaments that hold the bones together, allowing increased motion in the foot and a resulting shift in the bones, causing the deformity.
Gender. Women generally have more flexible ligaments to allow them to give birth, and are more prone to this occurring. Ligaments stretch more during pregnancy, adding to the looseness.
Ill-fitting shoes. To add insult to injury, many women's shoes are a major contributor to the deformity, as they often squeeze the toes together due to tight narrow toe boxes often found on many fashionable shoes. This constant squeezing is like braces on teeth that shift the teeth through constant pressure.
High heels add even more force on the forefoot, which exacerbates the deforming force of the narrow shoe toe box.
While shoes by themselves probably don't cause bunions, they do speed up the formation and add to the amount of deviation of the bones, causing more severe bunions.