I used to activate Minecraft Windows 10 on my laptop with the Java activation code so from my Java account I can somehow transfer the game (Windows 10 Edition) to my new PC
You should have connected it to a Microsoft account, then you can log in to the new PC in the Microsoft Store (this should be a shopping bag with 4 colors in the task bar) and download it again.
Usually, yes, with your Microsoft account, you should just be able to download it from the store again