Mac randomly crashes, main boot volume disappears
To answer your question, is it hardware or software.

Suggested course of action would be

1- Back up you data

2- Do a "Clean Install"

That should eliminate an formatting issues your SSD had.

If problem occurs again, your SSD needs Replacement/Repair.