How do game engines like UE4, Unity, Source, Cry Engine, etc add different rendering library's to their game engines? (Eg. OpenGL, DirectX, Vulkan)
Most game engines will have a layer between their rendering abstraction and the actual rendering API. In Unreal and Qt this is called the Rendering Hardware Interface, or RHI. I'm not sure if the others use the same terminology.
Typically the rendering engine will make high level calls to the rendering abstractions, and it will be the job of the various RHI implementations for different rendering APIs to translate those into actual rendering calls.
Supporting the various APIs isn't actually all that complicated since they all tend to do roughly the same things, just with different names. Probably the biggest engineering challenge is that each one of them uses a different shader language. Since game engines want to allow developers to customize the shading, they have to provide some common shading language or customization system that can then be translated into each of the languages and dialects needed by the different rendering APIs. This is far harder than just mapping a rendering abstraction to OpenGL, Vulkan, Metal and Direct3D.