>>1432346Black or very dark green is the most common color for steam locomotives because of costs and aesthetics. Steam engines are extremely dirty with coal dust, soot, oil, and general dust and dirt from running. Black hides these stains well, any other color will get dirty-looking very fast and require frequent cleaning. Also painting a locomotive multiple colors was very expensive with no gain.
As for the black and red combo, I don't think it's as common as you think outside of Germany. From what I've read, red running gear and wheels made it easier to spot defects like cracks. But having a little color trim goes a long way to improving a plain black locomotive without having to paint and constantly clean the whole thing. Also keep in mind red was historically one of cheaper colors.
Other cases like
>>1428372 are because red was that particular roads color.