Naturally, your body tries to get rid of muscle and store fat naturally for survival purposes.. Muscle consumes a lot of calories to maintain, so for survival purposes your body will constantly try to get rid of muscle, and store as much fat as possible. Your body's fat storage also is best used for low intensity, long exercises such as walking or hiking, your body's carbs and glycogen are used for higher intensity exercises and for muscle fuel.
Given the above info, bodybuilding is an attempt to fight your body's basic urges, so eating more calories than needed makes it easy to gain muscle. The hard part is keeping the muscle while focusing on losing fat, because of the way your body's biology works.
You can technically lose fat on a bulk but it requires exact science and a PERFECT diet consisting of PERFECT macro ratios, and the PERFECT amount of exercise. Some bodybuilders also just consume extra calories and go for many long walks throughout the week, I'm talking two hours a day sometimes to cut the extra fat you gain.. but it's difficult. Same goes for cutting, your body is going to think you don't have enough calories or nutrients so the first thing it is going to get rid of after a couple weeks of cutting is your muscle, because it is calorie expensive to maintain. Cutting always loses a little bit of muscle and bulking always puts on a little fat, You can use some science to meet in the middle, or just go on a maintenance diet, but again, unless you're going for long hikes everyday or just have a team of nutritionists planning out your diet to a perfect plan, which is near impossible because even fitness experts cant accurately tell how many calories of lean muscle or pure fat you're going to burn/add during exercise with diet to an exact number, with extra variables such as cortisol, sleep, stress, hormones, ---you can already see how complicated this is getting right? Best thing is to prevent as much fat from accumulating during a bulk as you can, and prevent muscle loss during a cut best that you can.