People usually say that if you eat less calories than you spend, than you'll lose mass (and this is not my objective, since I want to gain muscle, but lose fats), and if you eat more than you spend, you gain mass (and this is my current objective, but I only want to gain muscle mass, and lose fats). How much should I eat to gain muscle and lose fats? ( Considering that I work out for 1 hour about 4 times a week)
If you go into caloric deficit, you'll lose far more fat than you'll lose muscle. Any type of maintenance workouts will help you retain muscle mass. The only issue you'll have is that the caloric deficit might make you more exhausted, and not lift as heavy as you would during a bulk, for instance.
I've read MacUserT's answer (now deleted), and I somewhat disagree with the notion that you should be focusing too much on your protein intake. If you eat too much protein, the body will simply convert the surplus to fat during a process called gluconeogenesis.
Since we don't know your build, we can't give any detailed advice, but in general, you should be able to make all the changes you want, just by keeping track of what you eat, and how it affects your weight. You'll soon find that you can make small adjustments and see the changes on the scale after a few weeks.
Every one is different, so you're gonna have to find what works for you through trial and error.
The literature consistently reports values of around 1.5-1.6 grams of protein per kilogram of body mass per day (g/kg/d) as being optimal for endurance, strength, and power athletes—with up to 2.0 g/kg/d being recommended for ultra-endurance and multi-sport athletes, or athletes in significant energy deficit. The latter figure is appropriate when training for simultaneous muscle gain and fat loss.
Energy deficit should be limited to ~40% or less since the greater the deficit, the slower the muscle gains, and the nearer we approach a state in which muscle atrophy is inevitable.
It is imperative, of course, that a high-protein diet be accompanied by strength training. And long-endurance work, which tends to atrophy type I (slow oxidative) muscle fibres, should be kept to a minimum for optimal results.
I hope that answers your question directly.