This works sometimes when a hard drive has worn out of tolerance and the platter spindle or head arm are not moving properly or are stuck.
Put the HDD in a static bag
If you happen to have one of those silica packs (the ones that say not to let kids eat them) they help keep things in the bag dry
Fold the bag closed and tape it shut
Put it in the freezer for ~30 minutes
Take it out of the freezer
Take it out of the bag and let it sit for a minute. as long as your humidity is low and you don't get a lot of condensation on it you're good to continue
Connect it to your PC via a USB adapter and immediately try to read the data off to another disk. Dont try to boot to it as this wastes time and warms the drive back up so it will be more likely to fail early in your data recovery.
You can't recover the data if the system is not detecting the drive, that's why wise people keep backups of everything on a second or even a third drive.
For a non-detected drive, the only way to get any data off it is to take it or send it to a data recovery specialist service, which is very expensive (another reason why keeping backups is so important).
The "freezer trick" is a myth, but you've nothing to lose by trying it