Whatever Windows version you choose to install on the Mac, it came with a key.
Keys from OEM boxes are attached to that motherboard, but retail keys should do it. Make sure you purchase the right version.
The product key can only be used on a single PC or laptop at one time. If you have the retail version of Windows, then you can simply uninstall it on the PC it is currently install on, and the install it on the Mac. If you purchased a brand name PC (Dell, HP, Lenovo), then that is the OEM version and it is tied to that specific PC or laptop.
You can still install Windows without a product key, but it will only be valid for 30 days... at least that's the case for Win 7. Not sure about Win 8. After the 30 days you will then get messages stating Win 7 may not be genuine, the wallpaper will simply be a black background and you can no longer install any Windows updates/patches. You should be able to "re-arm" Win 7 to extend for another 30 day of legal usage. I think this can be done for a max of 3 times for a total of 120 day of legal usage. Afterwards, you must use a valid product key from Microsoft to get a fully functional Win 7 OS.