Kevin, the reason for this was to provide protection against the high tempratures of those surfaces.
As Casey indicated, most railroads really didn't use paint on these surfaces, it was an oil and graphite mix that was wiped on. In later years, regular paint was used, hopefully with high heat resistance.
We had a discussion on graphite here recently. Use the search option and I'm sure you'll find it.
Mike