When swapping HDD/SSD/M2 whatever it is, and it has a OS on it, it is better to do a clean and fresh installation of the OS, here is why.
The reason it won't work is that when you install an OS on the HDD/SSD it also installs specific drivers for the chipsets of the motherboard that it's using, so by taking that Storage with OS and putting it in a different PC with a different motherboard that has different Chipsets and Drivers, well, you understand what will happen.
(When I was young I tried it, and saw the beautiful screen of death xD)
1: So what I'm recommending is, download the Windows OS onto a USB Stick.
2: Take the SSD out of your old PC, replace it in your new one.
3: And lastly, do a fresh and clean installation of the...