Carbohydrates are one of the three energy-providing macronutrients, alongside protein and fat. One gram provides about 4 kcal. Your body stores them as glycogen in muscle and liver and uses them mainly as fuel for intense work such as high-volume lifting.
Their place in your macros
In the usual order, you set protein first, then fat, and the remaining calories go to carbohydrates. More carbs usually support training performance. For the off-season, Iraki et al. (2019) suggest at least about 3 to 5 g per kg of body weight.
Example: At 80 kg, 3 to 5 g per kg means 240 to 400 g of carbohydrates a day. These numbers are a worked example.
In a cut, there is less room, because calories go down while protein stays high. Carbs are still not bad there: for fat loss, the deficit is what counts, not which nutrient is missing.
Why they move the scale
Every gram of glycogen is stored with about three to four parts water (Kreitzman et al. 1992). When you eat more carbs, your weight goes up within a few days without any fat gain. When you eat fewer, it drops accordingly.
If the change is lasting, for example when starting a cut, going low carb or switching to a bulk, the trend makes a step and then continues at the old rate. A single big pasta night shows up as a short spike instead. To judge your rate, only the slope after the step counts.
In short: carbs make you heavier quickly. They only make you fatter through a calorie surplus, like any other energy source.