The Great Train Robbery (1903 film)

In that movie, there are two scenes which seem to show action overlaid on the present scene. One scene is on a stage representing a railroad office, but through the window you can see a train arriving and then departing. While parked you can see people on the train moving. Another scene takes place in a mail car on the train, with scenery viewed out an open door appearing to move by.

That seems pretty sophisticated for such an early film - how did they do it?

(I’m assuming the extra views are not ‘real’ but are overlaid somehow - correct me if wrong)

Simple double exposure. You shot the scene with a portion of the screen blocked off (and thus unexposed), then rewound the film and shot it again, making sure the train was in the unexposed part and blocking the rest.

George Melies had pioneered the technique several years earlier and Porter certainly knew of it.