This is a very frustration issue and I am banging my head against the wall.
I have an old iMac Intel 21.5" EMC 2389 iMac I salvaged from my parents and the drive failed. I added a new 1TB WD drive to replace the old 500GB WD drive:
https://www.ifixit.com/Guide/iMac+Intel+21.5-Inch+EMC+2389+Hard+Drive+Replacement/6284
Tried to do a clean install of OS X and it kept going into an installer loop after the first install reboot (would go back to the start and ask you what drive to install to etc.).
I finally figured out that the newly formatted internal hard drive is not bootable despite me partitioning and formatting it with the GUID Partition Map. If I select the drive in Disk Utility and click the info button the drive is listed as bootable = no.
So the installer plugs away, installs the first wave of files then reboots expecting it to boot from the target but it can't so it goes back to the installer USB stick again.