Chosen Solution

Can I swap SSD between 2015 and 2017 MacBook Air? Are they compatible?

Yes, those machines use the same type of SSD board. May I ask why you want to do this?