We won't prevent it until people learn to start talking to each other with compassion instead of hostility. As it stands, both sides think the other side is completely insane, and to some extent violent, and that they should not be associated with unless you are harassing them.
We've already burned the whole bridge down, and now need to rebuild it somehow. If republicans and democrats were separated geographically they might just split the country in two, but as it stands nearly every state has a large population of both, so in my opinion the only way forward is reconciliation.