Bunions are most often inherited, so it is unlikely that you did anything to cause it. Certainly, wearing shoes that crowd the toes - such as those with a tight toe box or high heels - can cause the pain and swelling that you have been experiencing.
We have two basic options to deal with this problem. We can change our shoes to fit our feet, or we can change our foot to fit the shoe. Initial treatments are aimed at easing the pain of bunions, but they won't reverse the deformity itself. Wearing roomy, low-heeled shoes; wearing a bunion pad to cushion the bump; icing and taking over-the-counter anti-inflammatory medications like ibuprofen or naprosyn; and using custom orthotics in the shoes are common options.
When the pain of a bunion interferes with your daily activities, it's time to discuss surgical options with your podiatrist, so together you can decide if correcting the bunion is best for you. Your podiatrist will perform a thorough exam, including x-rays, to determine a treatment plan with the goal of eliminating your foot pain.