The one thing people who support both Trump and Sanders have in common is that they are pissed off at the government for not doing its job. Trump folks are mad at the Republican establishment for not doing more to stop President Obama and the Democrats from advancing their liberal agenda, even with majorities in the House of Representatives and the Senate. The people who support Sanders are mad because President Obama didn't move far enough to the left, which is kind of stupid, because Pres. Obama and the Democrats have done quite a lot in the way of getting what they want during Obama's two terms in office. This is where the similarity between the two groups of voters ends
Socialism can be used to explain the popularity of Bernie Sanders. He promises lots of free stuff, This is Democratic party standard operating procedure. It worked with Obama's election. Bernie is going beyond free stuff though, he is promising a utopia. The idea of a utopian society is one that has been around for a long time. A utopian society would require a socialist government, and for some reason, socialist governments usually demand an atheist populous. Or, maybe it works the other way around. First people lose their faith in God. If their is no God, then there is no afterlife. This life is all there is, so a person needs to make the most of it. If there is no Heaven after this life, then we better create some kind of heaven on earth; a socialist/utopian society.
Capitalism is, at least, part of the reason for Donald Trump's popularity. I will attempt to use Christianity, Capitalism, and the "Gospel of Prosperity" to explain Trump's popularity. Christianity and Capitalism are connected by the Protestant Work Ethic/Gospel of Prosperity. Many Evangelical/Fundamentalist Christians believe that if they live good lives here on earth, God will allow them to prosper here on earth through a Capitalistic economic system. This is one large group of people who are supporting Donald Trump. The other group that likes Trump are the people that believe he will do something to fix the immigration problem. Ann Coulter wrote a book called Adios America in which she stated that any Republican could win the 2016 election simply by running on an anti-immigration platform. That is exactly how Trump began his campaign.
So, maybe it's more of an Evangelical/Fundamentalist Christian vs. Atheist thing than a Capitalism vs. Socialism thing. Trump has the support from Evangelical/Fundamentalist Christians, anti-GOP establishment (pissed off), and anti-immigration voters. Sanders has anti-Democrat establishment, and youngsters, and Utopian/Socialist/Communist voters in his camp. Trump just might become the GOP nominee, but Sanders doesn't have a chance to become the Democratic nominee. He is too far behind Hillary Clinton at this point in time. But, it is just amazing to me that Trump and Sanders have so much popularity.