Magnetoelastic coupling and the formation of adaptive martensite in magnetic shape memory alloys