Trying to cut fat and add muscle

Hello! I have been using the myfitness app and website for a little over a month now. I find it very helpful, especially at the end of the day to help me determine if I can still fit in a snack without overloading on fat, calories, etc. I am learning how to use the reports and graphs but it can be tricky.

Interestingly, I joined a gym at the same time I began using myfitness. They did a body analysis report for me when I started and just did another yesterday. I have lost 8 lbs in that time but I was surprised to find that I lost 2.7 lbs of muscle even though I have been doing weight training at the gym. I believe I've been doing a couple things wrong:

1. Doing too much cardio and not enough weight training at the gym
2. Probably more importantly, I've not been getting enough carbs, especially prior to weight training.

Like everything, the more you learn, the more you realize how much you don't know!