To clarify for the OP: First of all, Nitinol does not contract when heated, in general. Like any other material, it expands when heated (here [pdf file] are the thermal expansion coefficients for Nitinol; they’re in the same range as, say, steel). It doesn’t help that some Web sites (like this one and this one) repeat the claim that Nitinol contracts when heated. Sorry, just not so.
However, you saw something in a demonstration where it appeared that Nitinol contracted when heated. What you saw in the demonstration was certainly associated with the phase change of Nitinol, from martensite (low temperature) to austenite (high temperature). Here’s another page (a little more layman-friendly, IMO) all about NiTiNOL and phase change. In the phase change, the crystal structure of the material will change. In the case of Nitinol, there’s a substantial change in physical properties associated with the phase change; these changes can be exploited to do some interesting things.
One of these interesting things (which you might have seen) is a Nitinol wire with a bias spring. It works like this: One of the properties that alters with the phase change is the stiffness of the wire. You heat the wire, it changes phase and gets stiffer. So when a Nitinol wire is paired with a bias spring, the spring will stretch the wire farther at low temperatures (less stiff martensitic wire) than at high temperatures (more stiff austesitic wire). So the wire contratcs when heated, but only because the spring stretches the wire out at low temperature.
Another interesting thing which you might have seen is the shape memory effect. If a piece of Nitinol is “trained” into shape at a high temperature and then cooled, the metal will “remember” that shape if it is distorted (this page again has an interesting demo). Deformation of the low temperature martensite looks like permanent plastic deformation, but is really only shifting atomic bonds. When the material is re-heated, it will snap back into shape as the phase change alters the crystal structure. This has been used commercially for pipe couplings: form a coupling at high temperature, cool it, and stretch it out. When re-heated, the coupling will “shrink” back into shape. The same procedure can be used for wires: stretch them out at low temperatures, and they’ll shrink back into shape at high temperatures.
Additional note: there is a volume change of the material associated with the phase change (despite claims to the contrary on some sites). However, this volume change is relatively small: about 0.16%. And, if I’m reading this right, the volume actually increases when Nitinol is heated from martensite to austenite. It’s doubtful that this had anything to do with what you observed, though.