If the computer works fine aside from having trouble detecting the HDD, it could be the HDD but it could also be a problem with the motherboard, the SATA data cable or the SATA power cable.
Simplest way to test would be putting the HDD in a different PC or external USB enclosure and see if it behaves differently. If you get the same result, the problem likely is the HDD.