There is a difference between a low calorie diet where your body will cannibalize muscle cells and the fasting state where it doesn’t. Long story short when your body switches to ketones for energy there are mechanisms that stop that from happening.
For the long story here is a good start: