As hamluis has already noted, and particularly if we're talking Windows 10 (but it applies to earlier Windows, too), the license is generally linked to the actual machine on which the OS is installed. Windows 10 uses the motherboard ID as the unique identifier that gets stored on Microsoft's servers as part of the digital entitlement.
You cannot take a hard drive where Windows 10 was installed on "machine 1" and then take that hard drive and plug it in to identical "machine 2" and expect it to work. Windows 10 is not legally licensed on "machine 2" and that will be immediately detected by the OS itself when it re-checks the digital entitlement.
Windows is licensed for the specific instance of a given make/model of machine on which it is originally installed. Windows is not licensed for another physically identical instance of that same make/model and transplanting a hard drive into that other instance doesn't work.
Brian AKA Bri the Tech Guy (my website address is in my profile) Windows 10 Home, 64-bit, Version 1709, Build 16299
Here is a test to find out whether your mission in life is complete. If you’re alive, it isn’t.
~ Lauren Bacall