How does shape memory work?
The easiest way to understand shape memory is to remember that what's happening inside a material (at the nanoscale of atoms and molecules) may be quite different from what seems to be happening on the outside.
Stretch an elastic band and, inside it, the long, knotted rubber molecules untangle and tease apart. Remove the stretching force and the molecules pull back together again. That's essentially how elasticity works. Shape memory is different. Bend an object made from shape-memory alloy and you deform its internal crystalline structure. Let it go and it stays as it is, permanently bent out of shape. Now apply some heat and the crystalline structure inside changes into an entirely different form, prompting the object to revert back to its original shape. Pseudo-elasticity is similar, but no temperature change is needed to make the object return to shape after you deform it. If you bend a pair of shape-memory eyeglasses, the stress you apply makes the titanium alloy from which they're made flip into an entirely different crystalline structure; let go and the crystalline structure reverts back again, so the glasses spring back to their original shape.