What could have prevented this lottery?
That's a very difficult question to answer; one I think that depends more on the opinion of the person answering it than it does on anything else. However, I can give you my take on how a patriarchal, ritualistic homicide might have been prevented.
One of the primary reasons that the lottery took place they way it did is because of the male-dominated society Shirley Jackson sets up in the short story. Women are subjugated, and there are many examples to this effect. Some of the men talk to their wives in a demeaning way, one man even saying to his wife, "shut up, Tessie."
Subjugation of women allowed men to control most parts of everyday life, including reproduction. According to an essay by Oehlschlaeger, the inherent structure of the lottery made it such that a woman with the largest family stood the best chance of not drawing the black dot.
It would seem to me that a patriarchy gone wrong, run rampant, if you will, coupled with mob ideology and ignorance were the primary factors that allowed the ritual to continue. Ignorance is presented in statements made by Old Man Warner regarding the connection between the lottery and the harvest, "Lottery in June, corn be heavy soon." In addition, most citizens of the town seemed to buy into the superstition and ritualism that fed the lottery. So how to prevent it... Education. Education and a willingness to accept change.
The Lottery itself occurs because the town believes in it. There is an idea known as "collective conscious" that is a part of mob mentality. Every person in the group is locked into one idea, and because the group's energy, can not see beyond that idea. The people in this town are like that. Uneasiness with the ritual is suggested before Tessie's outburst. Consider Mrs. Adams' comment: "Some places have already quit lotteries."
Old Man Warner quickly shushes her, and others, although clearly nervous, don't step forward. The are all unable to overcome the consciousness that suggests the necessity of this ritual. Its a superstition that no one can bear to test.
So, how to break it? Like anything in life, a loud enough voice, with enough confidence, to turn the consciousness away from the old men (Warner, Sumner) and to another. One confident, strong voice speaking to the crowd, drowning out the voices of old, can create a new consciousness.
Unfortunately for Tessie, no voice steps forward.