It is unlikely that Nazism could have been prevented, although it may have been contained.
The general thinking is that the economic sanctions put upon Germany as a result of World War I + lingering nationalism from the 1800s + the economic collapse in the late 1920s made conditions ripe.
Without those conditions, Nazis still likely would have existed but may have been a minority party.