With my previously adopted body mechanics I was always kicking with hips closed regardless of whether I was active or not. Then I switched to open hips, but I thought for sure the default closed hips would creep back after inactivity. Well they don't! Open hips stay with me now regardless of whether I stope stretching or not. Is this what you call muscle memory? Here's an example after many months not doing anything.
Yes It has been proven in studies that flexibility is largely due to strength and mind. You muscles learn to contract to protect themselves at a certain stretch. Different for everyone. There are some other things at play but that is the basics. Pavel tsatsouline is a good reference to check for this