Locomotives were many colored and brass trimmed when they were assigned to a particular crew. Pride was involved and no self respecting Engineer and Fireman team would come into a home terminal with a dirty engine. Assigned engines were good for keeping the engines in top shape but when a locomotive was down for shopping the crew didn't work and when they didn't work they didn't get paid. Enter the unions.
Once locomotives were pooled and engine crews went on rotation in the beginning of the last century the shiny colored boilers and polished brass quickly turned to black anyway so may as well just paint them black.