Yes you can swap the SSD to another 2015 model as long as it is an original Apple SSD.
If your laptop contains a third party NVMe SSD, then you can only swap them if the donor laptop already has had macOS 10.13+ installed at some point since the laptop needs the system firmware that is only available starting with macOS 10.13+ in order to work with NVMe SSDs. In fact I would install macOS to the donor first so that the system firmware is at the same level as your current laptop.
The downside of moving the SSD to another laptop is the laptop's serial number will be different and that may affect how your AppleID is associated with that laptop.
Plus the most dangerous part of just moving the SSD to another laptop is that you will no longer be able to prove you are the legitimate owner of the laptop in case the laptop ever becomes disabled by FindMy or if a firmware lock is ever enabled and you don't have/remember the password. In fact you would want to confirm the used donor laptop does not have a firmware lock enabled and that it is not still being managed by the previous owner through an MDM (best to perform a clean install with the laptop connected to the Internet although sometimes the MDM management notices may take days or weeks to pop up). It would be much safer to swap Display Assemblies instead although that involves dealing with delicate easily damaged connectors.