Planck 2018 results. IV. Diffuse component separation