maybe on your desktop it's m2/pciexpress and on the Dell Optiplex 7040 mff it's a m2/Sata.
if it's a m2/sata, not compatible with the m2 card you have.
https://community.spiceworks.com/topic/1920845-installing-an-m2-ssd-into-an-optiplex-7040
I can confirm that the Optiplex 7040 is compatible...