The same way as you originally activated it, by key, msdm (if present), hwid, KMS_VL_ALL or kms38. With keys i can't help you, hwid or kms38 check my sig or google for massgravel github.
If You changed/replaced mobo and CPU, then it's a new or if not new then at least different computer and everything begins also from beginning, but if You had genuine activation, You can ask Microsoft to change Your computer and it will be activated agan, but the old will deactivated. If it was activated by using any med, do as said before/above and everything is OK again.
Let me ask a related question here. I built a computer for a friend of mine, back in 2011 or 2012, thereabouts. He’s still using the computer, it was upgraded to Windows 10 by Microsoft back when they were pushing that upgrade to Windows 7 users. My friend is a bit of a stickler about only using fully licensed software. At the time, he had a subscription to MSDN through his job, and he used a key for Windows 7 obtained through that subscription. He has since retired, and no longer has that subscription or any access to Microsoft licenses. If I build him a new computer and install Windows 11 (without activation), can he get it activated by calling Microsoft with the original license information? Mind you, this would be in the form of a license key for Windows 7 obtained through an MSDN subscription. Yes, I realize this is a little convoluted, and it would be much easier to just generate a new hardware key using one of the many tools available. But as I already stated, he is a bit of a stickler about such things.