It sounds like you are using a specific brand (OEM) Windows DVD such as one labelled for HP, Dell, Toshiba, Fujitsu etc. use. Most of those will only work on machines by that manufacturer as it checks the firmware/BIOS to make sure the hardware is of that manufacturer since their license from Microsoft is limited to only machines of those types. If your product key contains OEM on the sticker, that's a definite sign of this.
Or, you may have a multi-version Windows DVD for Windows 7 Home + Professional + Ultimate but your product key is only allowed for something like Home and it tried to install the wrong one.
Also, if it's a hacked/pirated multi-OS selectable DVD, those typically won't work (and aren't supported for use by Apple regardless).
You should also check to make sure your version of Windows 7 (i.e. 64-bit Professional or 32-bit Home Premium, etc.) is compatible via BootCamp with your specific iMac according to this table:
System requirements to install Windows using Boot Camp for macOS - Apple Support
Some iMacs only support 32-bit, some only support 64-bit, etc. So it would be good to know what Mac model you have as reported under menu > About This Mac.
The bottom line is that anything short of a full-install, stand-alone boxed and retail DVD that you purchased yourself for $150-$200 at the store (or a direct ISO download from Microsoft.com) is not likely to be successful.