With the original Windows® DLLs all the system used was the 'name' of the DLL in order to load it. These are listed in the import section of an executable. That was the main cause of compatibility problems - there is no version information included in the import section of the PE information to tell Windows which actual version of the DLL it needs. But when the program was originally built it does know the version of the DLLs it will need to run.
This is where Manifests come in, they describe the executable itself and the environment needed to run it. Each program component (EXE or DLL) should have a manifest to describe it. Each assembly typically has an 'assembly identity' that describes the name, author and version of the program and more importantly 'dependentassembly' to define which system components the program needs - and specific version information.
InspectExe display of a Manifest
Side by Side assemblies
To manage a range of different versions of a single 'named' component Microsoft puts all potentially sharable DLLs in a special set of folders called Winsxs for 'Windows side by side'. As there are different versions of the same DLLs with the same name they live in separate folders and the folder name is encoded with the manifest's version number for the component. This allows a component to be safely shared - the windows loader located the matching one - and multiple versions of the same component to be active at the same time.
InspectExe is an easy to use tool that lets you view the manifests contained in executable files. This lets you work out why programs will not load correctly.