All our energy comes from carbohydrates because the muscles get their glycogen which they use for energy from the breakdown of carbohydrates. But eating carbs in order to help you gain muscle needs to be carefully considered as eating simple sugars is definitely not the answer.
We need to understand the difference between a simple carbohydrate and a complex carbohydrate. All simple carbohydrates are sugars like glucose, fructose and sucrose which are just one or two molecules attached to a sugar molecule. Complex carbohydrates are made of three or more sugar molecules and will include all starches as well as any fiber.
Complex carbohydrates take longer to break down into glucose so this means that the use of glucose for normal bodily functions and any activity done means that it will be able to be sustained for a longer period of time. The effect when trying to build muscle will be radically changed when glucose is gotten from complex carbs as opposed to simple carbs.
For example a person trying to do a bodybuilding workout for an hour if they have just taken in some French fries and some hot chocolate will not be able to keep their strength up for an exhausting high intensity workout for an hour. The energy that they have consumed is quickly broken down as it is made up of simple sugars and is used up quickly.
If the same bodybuilder has just had a good quality whey protein shake an hour before his training session he would be able to complete his hard workout without a problem and without running out of energy. If complex carbs are responsible for the energy production in the body it burns a lot cleaner than with simple carbs.