M.2 describes a physical format; SATA and PCIe/NVMe describe different interfaces and protocols. The motherboard must support the drive interface and physical length, not merely have a similar-looking socket.
Before choosing parts
Check SATA/NVMe support, M.2 keying and accepted drive lengths.
Read lane-sharing restrictions before using every storage connector.
Treat capacity and interface as specifications, not measured application speed.