Well, we've touched on the heritable and very early factors that might influence out thought down through our decades. We hope, certainly, that reasoning affects our beliefs, and Christians hope that the Holy Spirit affects how we view matters and what we choose to believe. I've rather dismissed how much advertising affects us, though I'm about to bring it back in a larger context.
Who we hang out with powerfully influences our opinions. One can modify that by examining who we regard as our True Peers versus who we spend more minutes dealing with. We might even regard people who we have little contact with as our social group: people we went to school with; coreligionists, especially in a small sect; members of our profession; a political cause with widely scattered members who keep in touch frequently.
I can intellectually trace for you how I came to move from socialist to postliberal, but it may just be that I hung out with evangelical Christians for religious reasons and found it more congenial to hold their politics as well. I have asserted before that bright students like to identify with those who claim to be the bright ones of society, and in their socially insecure highschool and college days adopt the views of those they think are coolest. I can certainly accuse myself of that, and have seen it in others. Law used to be a conservative profession, but as people saw how to use the law to effect social change, those interested in social change went into it, and it is more politically mixed now. Social work and psychology have been overwhelmingly liberal, and those entering those professions tend to acquire even more of those views. Librarians had the stereotype of being personally conservative and thus people expected a similar staunch defense of the status quo from them. But it is a female profession and thus focused on women's rights and women's lives, moving it into more liberal camps. First Amendment issues before the days of speech codes and political correctness tended to pit them against social conservatives. They work for governments and/or schools, allying them with Democrats - it is now a very liberal profession, partly because of who librarians associated with.
It's easy to see the evolutionary advantage of being in agreement with those around you. Yes, there may be some competitive advantage in showing the strength of independence within the group, but such things have their limit. If you live in Chief Wilbur's tribe, it is likely dangerous to take opposing views. We are social, we want to get along.
It's mostly a good thing.