First off, you have to remember what it is that causes weight gain. Basically – calories in/calories out. Food is stored as fat when you take in more calories than your body uses up. Keeping that in mind, any food you eat can be stored as body fat if you are not burning off excess calories.
Pasta and breads are good sources of complex carbohydrates, however, you have to eat them wisely. They are calorie dense and are high glycemic foods (if you follow the glycemic index) which means they have a higher impact on blood glucose levels. The key is moderation and when you choose to eat these types of carbs. Consuming pasta or breads several hours before a good workout help to increase energy levels.