First things first, to lose fat, you will need to be in a calorie deficit. This means that you must burn more calories than you consume. So, you could be more active to burn more and/or you could eat less to consume less calories.
To gain fat, you need a calorie surplus… where you consume more calories than you burn. If you are in a calorie surplus, but provided enough resistance training stimulus, you can increase muscle mass. More importantantly for most, there’s a few ways in which we burn calories, and overall this is called Total Daily Energy Expenditure (TDEE).
TDEE is made up of the following:
Basal Metabolic Rate
Non Exercise Activity Thermogenesis
Exercise Activity Thermogenesis
Thermic Effect of Food
As you can see BMR makes up most of your energy expenditure. This can be increased if you have more muscle, for example. Non exercise activity makes up the next biggest portion, which includes moving around during the day, from fidgeting at your desk to taking the stairs.
Next up is the calories burnt during planned exercise. This isn't a particularly large part as a typical 60 min workout might burn 200 calories (but can be more or less). This is quite small compared to calories that can be burnt from BMR and NEAT.
TEF lastly is expended calories digesting food and digesting protein requires more calories compared to fat and carbs. So eating more protein could help lose weight.