My guess is your hard drive is failing. Try running the Apple Diagnostics to see if any hardware issues are detected. Unfortunately the diagnostics do not detect many drive failures. I can provide another method of checking the health of the hard drive by creating & using a bootable Linux USB stick. Let me know if you are interested in this option.
If the hard drive is failing as I suspect, then the more you have the iMac powered on and the more you attempt to fix the iMac or access the data, the more likely the failure will get worse where even a professional data recovery service will be unable to retrieve any data.
You should always have frequent and regular backups of your computer and all external media (including the cloud) which contains important & unique data.