My Mid-2012 Macbook Pro 13" randomly stopped working due to this issue. I thought my 8 year old OCZ Vertex 4 SSD was the culprit since my 10 year old Vertex 2 died in a Toshiba laptop.
The problem was the internal thin black flexible cable (less than 1 mm thick) that connects the drive to your Mac's motherboard. This cable's copper is fractured and transmitting data incorrectly making your Mac believe that it cannot find the boot HDD or SSD.
The cable is the weakest link since it is sandwiched between your hot HDD/SSD and the rough brushed aluminium macbook.
In the future, place electrical tape on the rough aluminum to reduce abrasion. The electrical tape backing is quite a slippery and smooth rubber surface. Tape is not meant to hold the cable in place, it acts as a comfy bed for the cable.
Apple later made a thicker cable with a diferrent model number to address this issue. Fortunately it is easily purchasable for $10-25 on Amazon (as of 2021) and was pretty easy to install with only a small philips screw driver.
There are 3-4 different cables for 2009, 2010, 2011, 2012 macbooks so get the right one. Cables are NOT interchangeable since they come in entirely different lengths and won't fit right. The cable model number is written in white on your broken cable.