Microstructure of martensite : why it forms and how it gives rise to the shape-memory effect