You can't turn fat into muscle, and vice versa. However, you can lose fat and gain muscle separately. This is often referred to as body recomposition.
Doing both at the same time can be tough for many people though. If you find it difficult to progress with both simultaneously, it may be good to focus on just one goal at time. Remember that even maintaining muscle as you lose fat is actually a great accomplishment, and same thing with minimizing fat gain as you gain muscle.