Building muscle and losing fat at the same time, in theory, won't happen. It is a dream for a lot of men carrying extra fat dreaming of building muscle and losing fat. To burn body fat you need to eat less and to add muscle you have to eat more, so it can seem downright impossible to have these two goals.
In general, there are several situations where you can build muscle while losing fat WITHOUT creating that caloric deficit that is otherwise crucial for fat loss...
1. You're weak and not strong enough but you wish to build muscle and make yourself look strong. Strength is directly related to muscle size. If you are average and only want to lose some fat on your belly for example, then you will gain muscle fast as you don't need to burn extra fat here and there from your body. You can go to a GYM and do weightlifting to gain muscle on your arms. You can do push-ups to gain muscles on your arms. By gaining strength on GYM excises, as a result, your body fat percentage will decrease and you'll look leaner at the same weight.
This is why so many weightlifting GYM goers have built muscle while losing fat with ease. They gained strength fast, built muscle as a result, and thus their body fat went down. This is called "newbie gains". It's pretty hard for a guy who has already had a good foundation of strength to build muscle while losing fat.
2. You've been well trained before. Science and technology are now backing up what GYM goers have been saying for a long time: it's easier to regain muscle than building it from scratch. If you have been trained and quit for a while and then resumed months/years later, you'll regain muscle faster than you first built it and are more likely to lose fat in the process.
Muscle has memory. If the program is taken properly, the muscle will be rebuilt, once the muscle is there, the strength will come back and will go forever at the same time. Men will look stronger than before.
3. You're a generic Freak. Some guys are born with magic metabolism and hardly gain any fat when building muscle. They have an athletic build although they don't go to a Gym often - usually mesomorphs. They hardly finish one round of push-ups or weight lifts and their body can burn fat easily to keep them looking fit. There are not too many men like this, most of them still need a program to burn fat first then build muscle.
4. You're Using drugs - Steroids. Some men go with drugs such as Steroids. They eat junk food always when they attend Gym programs. However you never see them put on extra weight. Why? The answer is simple - drug taker. Men use drugs to keep themselves fit. Actually those men are lacking confidence, inconsistency and motivation. They never learned how to stay smart and eat in the right way. If one day they stop taking drugs, extra fat grows very fast and they are never healthy. Wise suggestions for those men - Stop taking drugs, attend a healthy Gym program and control your fat and keep your life healthy.