Whether you want to maintain, loose or gain weight you need to know your calorie intake for maintenance. Let's start at the very beginning, calories (the little bastards/bundles of joy, whatever your take on it is), what are calories? 1 calorie is the amount of heat/energy required to raise 1kg of water by 1 degree Celsius. It's simply a unit of energy measured from food, that our body needs to survive. Knowing how many calories that are in the food that we eat, allows us to balance the energy put into our bodies and the energy we use.
Back to maintenance, this is the amount of calories required to simply stay alive at your current weight and complete your daily activities. Everyone is different and so have different activity levels, there is no one fits all when it comes to a calorie count. It has to be tailored to you! There are a number of methods to calculating calories. A very quick way is to use your total body weight in pounds times by a multiplier 14-16. This method is easy and fast but does not take into account activity level. For those who are very active, it may underestimate your calories count on the other hand if your body weight is much higher than average, it may over estimate your calorie count. A more accurate calculation would be to use the Harris Benedict equation however if number crunching isn't for you, an even easier way is to use 'my fitnespal' app (I should be sponsored by them).
In order to loose weight (specifically weight not just fat) you must be in a deficit of calories, your intake needs to be less than your maintenance, roughly 10-25% less. Eat less and your body will tap into its stores of energy. If you desire a drastic drop in weight, go for the higher end of the scale. However a less drastic approach, will be better for your body and allow your appetite to adjust, over a longer period. When dropping your calories for weight loss, you need to bare in mind that each week your weight may decrease and so your calorie in take will need to be adjusted accordingly.
Now for the fun part, to gain weight (aka eat all the donuts and peanut butter and burgers and pies), this is the opposite to a deficit, you need to be in a surplus going for an additional 10-25% calories. Add too many calories too quickly and it will be stored as fat rather than used for muscle development. When in a surplus you still need to take into account your change in weight to adjust your calorie intake. This change in weight may happen weekly or less frequently depending on your goal and journey.
Now this may seem less like rocket science and more like common sense but the fact that the nations growing number of obese cases escalate we can safely say it isn't common sense for everyone. To be honest I don't blame those who are unaware of energy expenditure, this is one of the many important things we are not thought at school along with what % AER are, taxes, credit score the list goes on.
Keep in mind when trying to loose fat or gain muscle remember not all calories are created equal.
Reference Venuto, T. (2013). Burn the fat feed the muscle. USA: Ebury Publishing. http://www.nhs.uk/Livewell/loseweight/Pages/understanding-calories.aspx