I have a product key for windows 7 and I have windows 8.1. How do I install windows 7?

You have to get a W7 DVD somewhere or ISO. Microsoft used to let you download it but I dunno why they stopped. Maybe able to get it from eBay. If this is a brand name ready-built, the vendor maybe able to snail-mail you one after your proof of ownership.