Physical properties of neutral gas in M31 and the Galaxy