The answer to that question is a bit complicated, but Hyce has a video explaining it. I highly recommend checking him out if you're into the more technical aspects of steam locomotives.
In cases like this, if the engine crew know they got a lot of photographers by the trackside they will over, fire, the engine to make the black smoke. They mainly do this for the pictures and the videos.
Amazing amount of black smoke. It tells you it's burning it's fuel very inefficiently. You don't see that with European and British steam locomotives. American train technology was always far behind that of the old continent, and still is.