Only way to gain weight is in a caloric surplus. Eat more calories than your maintenance. To find how many calories you should be eating just Google “calorie calculator”. Plug in your age, height, weight, activity level, and it will give you a general caloric estimate. I would recommend eating about 300-400 calories above your maintenance.
Also eat a lot of protein. Protein is what is used for muscle development and synthesis. 1 gram of protein per lb is what you should shoot for. Use the app “myfitness pal” to track calories and macros.
The most important part is LIFTING WEIGHTS and being consistent. There are a lot of fitness pages out there. One person I follow on Instagram is “brockashby” I also watch “will tennyson” on YouTube. They both have great content and you can learn a lot from them.
You will gain a little bit of body fat, but if all the steps are followed, you will definitely gain more muscle than fat.