The reasons as to why you are gaining weight may be because of lack of sleep stress or may be it runs in your family. However it may be caused by too many calories or lack of enough exercises. You can talk to your physician to ensure that it is not medical inflation.
Ask your doc to do a thyroid evaluation. Your thyroid IS your metabolism... so if diet and excercise isn't doin the trick (and you really have been sticking to it) there may be something else going on.