Ever watch a pro football game? The colored lines on the field (not the white yard markers) that show where the 1st down yardage is and the line of scrimmage look so real, but they aren't there, they're added by a computer program to the picture you see. What makes it look so real is that when players and refs cross the line, the line doesn't show up on them, like it's really on the field itself. That's because the computer is looking for the green color of the turf in the video image and only replacing that color with the color of the line. Once in a while you will see someone with a uniform or jacket that's the same tint as the turf and the life does show up on them, but that's rare.
The blue/green screen works the same way. A computer program is only looking for the exact shade of background color that was used and replacing it with the corresponding parts of the image they want to superimpose. They used to have to physically mask the reverse areas of each of the two images and then synchronize the two films and film them again together. That's why you never saw the camera move during those shots. With a blue screen, they can have any amount of action in both images and the computer will know where to superimpose the background image.
By the way, going back even further, those scenes inside moving cars, trains, etc, were shot on a movie set with a movie screen in the background showing traffic whizzing by, etc. Very low tech.
If you're into that sort of thing, you should try to find the deluxe edition DVD of the original "King Kong" with special effects genius Ray Harryhausen doing the commentary. It contains some very rare archival footage (the director ordered everything to be destroyed after the movie was made) showing how the different scenes were put together, with several cameras, models, the masked film technique, etc. Also, see the movie "Matinee", with John Goodman, a kind of tribute to Harryhausen, the master behind every monster movie in the 1950's and '60's.