According to the picture you posted, the old model you used was a Toshiba THNSNJ256G8NU and it's a SATA III SSD. It uses a "B+M" key edge connector, according to the picture you posted.
Here is what the "B+M" connector looks like:
Meanwhile, the new one you purchased and plan to replace it with is an NVMe SSD (Samsung Evo 970). It uses an "M" key connector.
The first thing you should check is whether your laptop supports NVMe SSDs or not. Many laptops only allow using SATA SSDs, only having a SATA III interface. Therefore, even if you can insert this new SSD into your M.2 slot somehow, it may not work at all.
I couldn't find full specifications of your laptop based on the model you posted.
The best replacement for you is this one.
After digging a bit deeper, I found this file from MSI, which declared that an "M" key SSD can only be used in an "M" key socket:
A bit deeper in the same document:
So based on the model you provided, you have 2 "B" key SSD slots, and 1 "M" key SSD slot. However, all three slots can only use SATA III SSDs. There is no way you can use an NVMe SSD at all.
So the one you have purchased (Samsung 970 EVO Plus) can't be used.