You are not alone in this type of thinking, infact i think many think this way. But the first thing you need to realise is that eating is essential everyday, and eating a certain amount each day is necessary as well. It doesnt matter if you are lying in bed for a week, or working or in school or out hiking or sitting by a desk all day. The body needs a certain amount of energy each day. Of course if someone is active they need a higher amount of energy each day, but even on the days that they arent very active they can most likely eat the same amount of energy as that is what the body needs.
I dont know whether you are underweight or not, but if you are then you need to realise that weight gain is a good thing, it is what your body needs and it is very counterprodutive if you are then going to starve yourself to lose weight just because the scale has gone up a little? Then it will just be +/-/0 all the time and you will just mess up your metabolism. It is like yo-yo dieters who end up with terrible metabolisms and can only eat very few calories because they have gone from very restrictive to eating lots to very restrictive. It messes with your body and your body will be constantly stressed and never find its balance.
Because the body is smart, the body adapts very well. If you eat very little for a long period of time the body will slow down the metabolism a little to keep the body functioning properly so that you arent burning so much energy as you arent getting so much energy into you. The body wants to keep you alive, and if you increase your food intake the body will do its best to try to burn off as much energy as it can to find a balance, because the body wants to be balanced. The body wants to settle at its healthy weight and keep you there so you function properly. But if you are going from eating lots to very little and back again to lots it will disrupt the balance and disrupt the bodies natural way of finding balance and can make things alot harder for you in the future.
It can also be good to acccept that you need to gain weigt. That is the first thing, maybe you can have someone else weigh you or maybe not look at the number at all? If the number on the scale triggers you too much then dont weigh yourself, instead focus on eating and eating enough while also battling your mental thoughts. Increasing your food is necessary even if you are gaining weight, as the increase in food will help your body to recover and nourish itself and to help fix the damage in your body.