You can't have it all.
To gain muscle you must increase your intake. To lose weight you must do the opposite.
So it's it's safe to say, if you want to lose fat you can't gain much muscle.
The first thing you should ask is, what i need to do first?
Do i have to much fat? What is my main goal? What is the first steps to achieve my goal?
If you have to much fat, let's say more than 14% of body fat, you should lose some weight. There is no sense on building muscle under fat.
If you have under 14%, you have some fat, but not too much, you can build muscle, and add just a bit of cardio so that you don't much fat, and have a proper diet.