Today many games are built using major engines, but some places and some games continue to use their internal game engines.
Basically it worked like this:
Start with a simple game. Make it work. Celebrate the launch of a product.
Take that simple game, remove the parts that don't make sense for the second game, add the parts that you need for the second game. Create and release the second game. Celebrate the launch of your second product.
Take that code, remove the parts that don't make sense for the third game, add the parts that you need for the third game. Create that and release the third game. Celebrate the launch of your third product.
Repeat several more times, each time pruning the things that don't make sense and adding the parts that are extra. Soon you'll build a common set of functionality that most of your games rely on. THAT is the engine.
In the case of Unreal, Sweeny started building games in 1990 and releasing them every few months starting in '91. By the time they hit Jill of the Jungle in '92 it was a fairly stable engine. I remember wasting a lot of time playing Epic Pinball and Silverball, both released in 1993, and I'm quite certain they reused a huge amount of the ever-growing engine for the graphics and audio. By the time they did a massive rewrite and created Unreal they were around game #40 or so.
Engine code tends to include the generic forms of graphics, animation, audio, networking, AI, math, disk access, and assorted other systems. The game includes assets like models, textures, animations, sounds, music, levels, plus all the code that combines the assets in interesting ways to create gameplay.