I think you are sleeping on a too firm matras.
It works the opposite. When muscles are able to relax they start to hurt.
Probably you are sleeping on a hard matras very long.
Then switching to softer make your muscles hurt temporary