Shape-memory alloys flip back and forth between two solid crystalline forms called Austenite and Martensite. At lower temperatures, they take the form of Martensite, which is relatively soft, plastic, and easy to shape; at a (very specific) higher temperature, they transform into Austenite, which is a harder material and much more difficult to deform. Let’s say you have a shape-memory wire and you can bend it into new shapes relatively easily. Inside, it’s Martensite and that’s why it’s easy to deform. No matter how you bend the wire, it stays in its new shape; much like any ordinary wire, it seems to be undergoing a very ordinary plastic deformation. Heat it up a little, above its transformation temperature, and it will change into Austenite, with the heat energy you supply rearranging the atoms inside and turning the wire back into its original shape. Now cool it down and it will revert back to Martensite, still in its original shape. If the material is above its transition temperature the whole time, you can deform it but it will spring back to shape as soon as you release the force you’re applying.