Many think this, but most can't lose fat and gain muscle at the same time. Only the physiologically blessed can do this. Also, if you are new to the weight room and it is a new stimulus for the body, then there is a short window where burning fat and building muscle is possible.
Put simply, to build muscle you must be in a calorie surplus and to lose fat, you must be in a calorie deficit.
You said you want to lose weight. In reality, you should only want to lose fat. Weight consists of fat, muscle, bone, tissue, etc. Too many people cut calories way to low, and don't supplement their exercise routine with weight training.
What weight training does, is help in the retention of muscle while on a small calorie deficit. When you are on a calorie deficit, you are undoubtedly going to lose SOME muscle, but if you eat right and hit the weights, you will maintain most of it.
This is important because muscle is a metabolically expensive tissue; meaning, just having more muscle on your frame increases your resting metabolic rate.