@fd
Which of those diets made you gain 5-10 lbs? If it did so, why did you stop with that diet?
If none of the diets made you gain weight, it could be possible you are hyperthyroid. Otherwise, one of them would at least work.
If you weren't hypothyroid, you would be metabolizing sugar well and what you eat would be utilized in building structure, among other things. Unless the energy is wasted or used up in being hyperthyroid.
If you were hypothyroid and not metabolizing sugar well, then a keto or carnivore diet would allow you to not to build fat as metabolizing fat is easier to do than metabolizing sugar, given efficient sugar metabolism is like doing a very complicated routine in gymnastics and many of us fail to do it well. And a carnivore diet means your muscle and protein stores simply convert to sugar when needed, so there is no chance for blood sugar to spike to high levels where a lot of insulin secreted by rhe pancreas would cause the liver to convert blood sugar to fat. Keto and carni would allow to build structure and gain some weight, however flawed those approaches are.
But you aren't.
What have you done by way of testing to ascertain you aren't hyperthyroid (much less hypothyroid? Are you hypothyroid, euthyroid , or hyperthyroid? This is not an easy question to answer, as most doctor s, even endocrinologists, get it wrong by miseducation by the Flexner Report- gamed medical system.
It's important you get this question answered satisfactorily. Or you're just throwing darts blindfolded.
OTOH, as you had briefly mentioned, you may also want to look if there is something wrong with how well your gut absorbs nutrients. Assuming your nutrition is free from making you deficient in macros, vitamins, and minerals.
Add: Toxins and infection and trauma arw faxtora to consider as well.