Contrasting the chemical evolution of the Milky Way and Andromeda