MS is activated when experiencing the loss of a loved one.

There was a great theory posted about Obito activating his MS while being crushed under the rock.

He experienced the loss of everyone he loved because in his mind he was saying goodbye.

Goodbye to his crush, goodbye to his new friend Kakashi, to his sensei, his clan, everyone else.

He had just gone through a tremendous amount of emotions and was saying his goodbyes.

His mind and body were both 100% convinced it was the absolute last time he would see his friends while living, thus experiencing true loss of loved ones.

This, in my opinion, is what activated his MS ability and allowed him to phase down into the ground where Madara was.

I think his MS is a unique case though because he was unaware of what or how he managed to escape.