your computer info is uploaded to microsoft servers when you activated it. if you reinstall windows 10 on the same pc you do not need to key in product key, it will auto activate.
For earlier windows you need to key in key, but if its the same pc, it will be reactivated. If you plan to reuse on another pc, it wont work