It mostly comes down to:
* How much and what kind of food you eat.
* How much and what kind of exercise you do (including daily life as well as specifically working out, playing sports, etc.).
* Genetics. Some people are hard gainers, some are easy gainers, and a lucky few gain muscle more...