If you want to build muscles, you need an overspill of energy, especially protein. As long as you burn more calories than you eat, your body is taking (saved) fat just to get enough energy for the metabolism scenes. This means, in general you can't lose weight and buld muscles simultaneously.More than that, if you eat much too less,your body will burn protein too. This will be taken from protein circulating in your blood and can't be used to gain muscles.
To lose weight you have to burn more than you eat. This process will activate hormons and your body gets into a catabolic state. To gain muscles, you need an anabolic state, which will be activated by hormons which are opposed to the catabloic hormons.
So it's not possible to have both simultaneously.
But you can swtich between both states even in a day. For example, you have dinner at 6pm. You don't eat anything else... in the morning after, first you do is running for 45min. Your body will burn fat (you may not run too fast) and the state is catabolic. After running, you eat protein, some carbs/fat and make sure to get enough vitamin and minerals. But the amount of calories is still less than you have burned since midnight. For lunch you eat healthy again, still less than you have burned in total. In the afternoon you have some protein before you do a full body workout or using weights to build muscles. Now you eat more, to have an overspill of calories and to gain muscles.
Just know, it's easier to focus on one thing for some time and then on the other thing.
"If you want to chase two rabbits, you will get none of them"
You can if all the circumstances are right.
It's not a guaranteed thing and it will be easier with for some than most.
A few minimal requirements are eating high in protein. Not going too crazy in your kcal deficit and heavy resistance training.
You can increase your fat free mass while dropping bodyweight.
A few thing will make it harder:
Being an ready training individual.
Being low in fat mass.
I'll keep this short and simple
For the most part. No. The 1st year you start working out and if you are consistent with both training, nutrition and sleeping. Yes you will experience both muscle gan and fat loss. After your 1st year it will become harder and progress will seem like it has halted, purely from an aesthetic point of view. You should prioritize your goals and pick one or the other.
*this is my advice, from my own experiences. Also from everything I have read and researched*