architecture – Generally speaking, how hard is it for a AAA project to change game engines?

I’m a hobbyist coder and have no idea what projects on the scale of AAA games look like as far as game engine integration.

From my perspective, I know smaller simpler projects like map rendering libs for HTML5 will use a class for an object being rendered that can easily use different rendering classes (handlers for SVG, CSS, Canvas) to render the some object based on the browser’s support or performance considerations.

Do the various game engines like Lumberyard and Unreal (or other major 3D game engines in general) have components similar enough for this kind of interchangeability to happen?

Do AAA developers often structure their projects with the consideration of changing to a better engine in the future?