What I don't understand though from a science point of view is how is it possible to not lose any weight or to gain weight when you are in a caloric deficit?
The thing is, if you're gaining, you're not in a deficit. You may be consuming a pitifully small and dangerously inadequate amount of food, but your body is burning even less than that in an attempt to survive. I kept thinking the answer to that was to eat even less, but the answer was to eat more and let my body feel safe to burn more. At the height of my restriction, I would gain on typical "diet" calorie recommendations. Now, after years of adequate fuel, I need 2-3 times that to keep from losing. So, it was about eating enough to let my metabolism and hormones recover. Then I began to gradually lose on significantly more food. Your natural weight is where you settle when you eat without restriction. For me that was quite a bit higher than when I was anorexic, but also quite a bit lower than the initial recovery weight I feared I'd be stuck at forever.