This is a common misconception. Fat, like other nutrients, provides essential components (essential fatty acids) that contribute to overall health and well-being. Fat does provide more calories on a per gram basis than protein and carbohydrates (9 calories/gram vs. 4 calories/gram respectively). The key to making sure one doesn't gain weight and or body fat is to not consume excess calories. Since fat does provide more calories, than consuming more fat may tend to lead to weight gain and excess body fat accumulation. By limiting one's calorie intake to the amount of calories one requires on a daily basis, then it is unlikely one will gain weight or body fat.
The key is to consume healthy fats in moderation. Healthy fats include monounsaturated fats (olives, olive oil, almonds and other nuts, avocadoes, etc.) polyunsaturated fats-omega-3 (fish, flaxseed, etc.) polyunsaturated fats-omega-6 (unrefined safflower and sunflower oil, nuts and seeds, etc.). Avoid the unhealthy fats such as trans-fats (packaged/process foods, snack foods, margarine, etc.), and excess saturated fats whole milk, ice cream, butter and red meat.
The bottom line is fats provide our bodies with critical components needed for survival, but, similar to other macronutrients (carbohydrates and protein), they should be consumed in certain forms and in moderation. Doing this will help reduce the risk of dietary fat contributing to excess weight gain and body fat accumulation.