The BAHAMAS project: the CMB-large-scale structure tension and the roles of massive neutrinos and galaxy formation