There are two parts to your question. The first is the data on the drives themselves. You can use a drive from one Mac, and install it in another Mac, and it will run just fine. All the drivers are built into the OS. The only trick is that the Mac you put the drive into must be compatible with the OS that is installed.
This means that you couldn't take a drive from a 2011 Mac running OS X Lion and put it in a 2019 Mac running Catalina, or vice versa.
Now, the other question is "will the drive fit in my Mac". You obviously couldn't put a SATA HD from a 2011 Mac in a 2019 Mac or even a 2015 Mac like you have.
However, the 2014 and 2015 MacBook Pros use the same SSD, so your swap will work just fine.
FWIW here's what the other years of drives look like:
View attachment 954531