You won't lose muscle if you exercise and eat a lot of fat.
When were talking about weight loss and weight gain it IS all about calories in vs calories out, you cannot refute the laws of thermodynamics. The question is what controls calories in and calories out? If you eat more than you use, you will gain weight, if you eat less than you lose you will lose weight. Energy cannot appear or disappear, it can only be transfered and change "form". That sounds very simple, but appetite control is a very complex topic.
And fat won't make you fat if you don't eat over your maintenance level of calories. It might be easier to eat over your maintenance level of calories if you eat a lot of fat (as some research has suggested), but then you're in a calorie surplus. If you gain fat at a maintenance level of calories you must be losing calories from muscle at the same rate as you're gaining calories in body fat. And if you do strength training and you're healthy, you won't lose muscle mass while you're at a maintenance level of calories. You might if you reduce the amount of training you do, though. But if we're talking about weight gain, it is impossible to gain weight in the form of fat or muscle or other tissue that consists of energy as long as you're in a true caloric balance. You could gain water weight, etc, but that's it.