Thanks for your query!
How long has this going on? In general, not being able to eat anything properly, with excessive concern for health specifically weight gain, being under weight with BMI less than 18, potentially raises concern for an eating disorder. These symptoms generally can start anytime from the peak of adolescence to early adulthood.
At the same time, I would be concerned about any medical condition which is mimicking/causing your current symptoms including
thyroid disorders, prescription medication use,
liver disorders, gastrointestinal infections, ,etc. Nonetheless, any weight loss pushed to the extreme can cause serious medical issues including
electrolytes imbalance, heart rhythm disorder, infertility, etc.
Next Steps
There are things that can be done for your symptoms. To start with, I suggest seeing an expert like a psychiatrist or a neuropsychiatrist for a thorough evaluation in terms of history, physical exam and maybe some blood tests. In the mean time, try eating foods that appeal to you. All the best!