Large surveys have shown that red galaxies are preferentially aligned with their haloes, while blue galaxies have a more isotropic distribution. Since haloes generally align with their filaments, this introduces a bias in the measurement of the cosmic shear from weak lensing. It is therefore vitally important to understand why this difference arises. We explore the stability of different disc orientations within triaxial haloes. We show that, in the absence of gas, the disc orientation is most stable when its spin is along the minor axis of the halo. Instead when gas cools on to a disc, it is able to form in almost arbitrary orientation, including off the main planes of the halo (but avoiding an orientation perpendicular to the halo's intermediate axis). Substructure helps gasless galaxies reach alignment with the halo faster, but has less effect on galaxies when gas is cooling on to the disc. Our results provide a novel and natural interpretation for why red, gas poor galaxies are preferentially aligned with their halo, while blue, star-forming, galaxies have nearly random orientations, without requiring a connection between galaxies' current star formation rate and their merger histor