Hello,
gaining weight has a lot to do with your health, genes, food and activity.
First of all, you can't change your genes. If you were meant to be thin, then your body will have the tendency to stay thin.
Your health may affect your weight. There are diseases that lower body weight like chronic infections (
tuberculosis etc),
diabetes mellitus,
thyroid disease, etc. Your doctor can help you by excluding health problems.
Food has also a lot to do obviously. If you're not taking enough calories then you won't gain any weight.
Physical activity results in energy consumption, which means that more nutrients might be needed. If you exercise a lot then perhaps you need more food.
Also physical activity that requires near maximal strength (80% of maximum strength or more) results in
muscle hypertrophy and weight gain. Exercises that require only 15-20% of maximal muscle strength will not pump your muscles. . .
So you need an assessment of your diet, physical activity and general health by your doctor.
If you'd like to provide more detailed information about the above, I'll be glad to help you.
Kind Regards!