There is really only one thing that causes muscle loss while an individual has sufficient bodyfat, and that is atrophy. If you don't stress the muscle enough, the body starts to eliminate it. People who lose large amounts of weight lose large amount of muscle because they aren't increasing their activity level enough to maintain that muscle mass. Let's say a 300 pound guy loses 100 pounds. To keep the same amount of muscle mass, that individual would need to maintain a level of activity equal to carrying around 100 pounds 24 hours a day.
When fasting, you can lose weight quickly due to a decrease in activity from the reduced calories. However, during a water fast a very unique thing happens. After about 48 to 72 hours, the body goes into ketosis or muscle sparing mode. You burn almost all fat and very little muscle. The theory behind this is that during a reduced calorie diet, your body thinks food is scarce, and less muscle is advantageous because it requires less calories to maintain. However, when you are on a water fast of 0 calories, your body thinks you are injured and unable to obtain food. So, it works in a way to maintain muscle mass so you still have the muscle when you are well enough to search for food.
I have done a lot of research on fasting, and I recommend water fasting over reduced calorie fasting. However, if you try and water fast from a dirty diet (meaning one with a lot of animal products, refined foods, etc), then you will likely develop very bad headaches and maybe some intestinal pains. If you start by eating a raw, plant-based diet for 30 days, then a juice diet for 7 days before your water fast, you will detox more slowly and it won't be a shock to your system.