He apparently figured out a lot of things in the moment, so a lot of it was learned instinct, but his use of color is so incredible that some of it has to be down to planning costumes, backgrounds, props then emphasizing color curves and contrast in film development. You don't accidentally do this: