An origin for multiphase gas in galactic winds and haloes