Whenever something funky is happening to a drive, back up all the important data on it immediately. Better safe than sorry, and the first fix I'd try is to essentially factory reset the disk, since you seem to have already tried the other fixes.
Try a USB to M.2 adapter. These aren't particularly fast but see if your computer can detect it when it is connected through the adapter. It should show up like a USB drive if successful.
Open Windows Powershell as an administrator to open a command terminal.
Run Get-Disk
in the terminal. Find the disk in question among the list and note what number it is.
Run Clear-Disk -Number 999 -RemoveData -RemoveOEM
, except with the target disk's actual disk number instead of 999
. This will erase all data on the disk. You won't be prompted for confirmation. Ensure you give it the right disk number. This might take a while to complete. You'll know it is complete when the PS>
prompt appears again. If nothing happens right after you press enter or the terminal seems to freeze, just wait. It is running.
After the drive is cleaned, try putting it back into the M.2 slots on your motherboard as usual and see if it is detected. If so, initialise the drive as usual (GPT is suggested if you are given a choice between GPT and MBR) and format it.