Yeah I was wondering the same thing a few years back. But let's just reason this out here. So, in order to build something, anything, you need something to build it with. That's obvious right? You can't build a brick wall without bricks or a staircase without stairs. Now, let's say you order 1,000 bricks and you want to build a wall with 900 bricks. Assume, on the way over, from shipping, about 150 bricks are lost so now you have 850 bricks. Well, can you now build a 900 brick wall ? No.
Similarly, at least if you're thinking purely in terms of calories in vs calories out, then you need to beat your calories burned. Your maintenance calories, i.e your resting metabolic rate, is how many calories your body burns on average in one day, even if you were to not do anything. Well, even if you overcome this number with food, what is your body going to use to build itself if it doesn't have anymore calories left since you exercised and burned, lets say 500 more calories? It wont.
For example, think of it the reverse way, when bodybuilders are cutting for a show, or a gym rat is cutting to get leaner, why do they add additional cardio? Obviously to burn more calories.
Your body can't build muscle if it doesn't have the ingredients in the first place because they were burned up doing other things. But to be fair, it isn't so black and white. Yes, calories in vs calories out plays a huge role, but so does protein synthesis. In fact, this is the most important process when you're trying to build muscle. For example, let's say you start to eat over maintenance, (by the way, it's usually recommended that you eat 16-20x per lbs of bodyweight for weight gain, while 14-15x for maintenance, so this alone should answer your question, look online). Well, if most of these calories are from carbs and fats, then you're not going to invoke protein synthesis. Remember, all muscle building is, on a technical level is Protein Synthesis vs Protein Breakdown. To invoke protein synthesis, you guessed it, you have to consume a lot of protein, manipulate insulin correctly, and make sure your diet lets you consume the max amount of amino acids, as well as lots of sleep.
In addition to your actual question, whatever you do, DO NOT listen to any post on myfitnesspal regarding fitness or even diet, the quality and accuracy of the articles are actually horrifying. I should also mention that while it is good that you're trying to look up information on your goals online, the best way to accomplish your goal is through time with experimenting and seeing what works best for your body, it is unique to you. Some guys can get massive with pop tarts and coca cola, while some will look like a sumo wrestler the second they even look at white rice (look up insulin sensitivity if you want to "optimize"). There is NOTHING that will beat pure hard work in the weight room combined with lots of and lots of quality food, I wouldn't even start counting until after a few months of figuring out how your body responds to weight training. Just my opinion.