I have an M2 500GB hard drive that I have been using as the boot drive for my windows 10 PC. One day the PC crashed and since then whenever I boot the PC it boots to a blue screen. So I decided to format the HD and reinstall windows 10. I used an M2 to USB connector and tried to format the drive but nothing works. I can read and see the files on the hard drive but I'm unable to format nor delete any of the files. I've tried gparted on linux, disk utility on mac and also tried to format the drive with windows, nothing helps. Is the hard drive faulty or somehow protected against formating?
The drive is damaged and the internal firmware is deeming the error to be non-recoverable. That is why it is locking it into a read-only mode to prevent the data from being destroyed. This is a common mechanism with flash storage of all kind, including M.2 and USB flash drives. The only thing you can do at this point is to get the data you need and buy a new one.