Neutrino masses and absence of flavor changing interactions in the 2HDM from gauge principles