Most of the times using different files for different things is just for organization, it's easier to add new things or fix bugs if you have a file with code that is related and everything about it is there.
The "main" file doesn't "put togheter" everything, it's just some piece of code that uses other pieces and you can (and will) have other pieces of code that uses some other pieces apart from the main one. For example, you can have a file with physic simulation code that uses the code from other files too (like a RigidBody file).
Every program has an entry point, which is the first thing that will be executed when the program starts, and at that point the code would check for different conditions to do different things. In a game and other visual applications the "main" code will have a piece of code that runs forever in a loop until you quit or will start some other code that does that. It's kind of standard to name that code "main", but it's not really different from other source code.
Anyway, when talking about programming you have a lot of things happening that depends on more factors. In some languages like C you do end up with one compiled file that has all the code in it (you don't have to make it, there's a compiler that will do it) even if you wrote different files. In other languages like JavaScript you have all different files that you have to put in one file if you want to (for optimization maybe).
Programming is really complex and, like Buckeye said, there are books about it. There's no short and easy answer for your question, and more important, there's not a unique answer. You should try to learn how more simple applications work before looking at a game's source code.