Check Hard Drive Connections
Another reason for this problem could be a bad connection between the hard drive and the computer's main board. If you're comfortable with tech stuff, you can open up your laptop to make sure the motherboard is still securely in place.
For a desktop computer, check the cable that links the hard drive to the motherboard. You can also try plugging it into a different slot. In that case, you might need to change the startup order to use the new slot.
You can also take this opportunity to clean your laptop because too much dust can mess up the hard drive's connection. If you're not sure how to do this or don't have the right tools, it's best to have a professional service take a look at it.