I don't know if there is a way to keep them from happening. Seems we all get them. There is a product my doc calls miracle mouthwash. A solution you rinse with that helps the sores heal. there is another mouthwash that will numb the mouth so you can get something to eat.
Rinsing with peroxide and water has helped too. My Oncologis suggested that I use that.
Maybe someone else will come along with an answer for how to prevent.
Best of luck to you,hope they get better.