A few things on this. These are just some generalized topics. We can get into specifics later if you want.
Weight gain or loss is “generally” dependent on simply 2 things - the amount of calories you consume and the amount of energy you expend.
(Yes you can modify your metabolism a little bit with what you are eating and how often you eat and what you eat, and how much activity you get. And there are some ways to do all of that, but for the most part it’s simply this - calories in versus calories burnt.)
Only considering weight gain or loss (not health or nutrition), it does not matter a whole lot what you eat to make up the calories. Like 2,000 calories that is 50% carbs versus 2,000 calories that is 35% carbs won’t make much of a difference for weight. Only a small factor.
So for weight, the primary concerns are eating the right number of calories, and making sure you provide your body with the right amount of the macronutrients - carbs, protein, and fat to be healthy. (This is not counting nutrients like vitamins and vegetables and such. That is a different topic.)
For muscle gain, you need to work your muscles and you need the right amount of protein (for repair) and carbs for muscle glycogen (stored carbs for energy). There is not really a diet that builds muscle by itself without also working the muscles.
For calories, every gram of carbs or protein has 4 calories. Every gram of fat has 9 calories. More than twice as much. And for the most part, fat is easier to manage for BG than carbs.
Fat give you more bang for the buck in terms of calories. So the easiest way to gain weight is to increase your fat intake though healthy fats (unsaturated fats instead of saturated fats).
The easiest way to remember “good” versus “bad” fat (unsaturated fat versus saturated fat) is that fats from plants are generally the “good” kind of fat, except for 2 things - palm or palm kernel oil and coconut oil. Most every other plant fat is fine.
And fat from animals are generally the “bad” kind of fat, except for fish, which are good. (Like pork is bad, tuna is good, etc.)
That is not a completely full list, but that is a fairly easy way to remember it and simplify it. (Totally oversimplified, but just easy. I can eat more of this animal, not this one. I can eat these plants but not these 2, etc. )
But the last thing is that you need to keep in mind is that you still need the proper amount of everything. You still need a sufficient amount of carbs and protein too. Like even if you only eat healthy fats, you still need the other macronutrients too. As well as the right amount of vitamins and minerals and water and fiber, etc.
Does that stuff make sense? Questions?