For folks trying to lose weight, the very idea that it can be hard to gain weight sounds pretty crazy. Guys who can't gain weight? Lucky guys, right? Eat whatever they want and stay skinny?
That's only great if you want to stay skinny. It's actually a bit of a curse if you don't.
The human body craves homeostasis. Basically, it wants to remain as it is. You have to work hard in the gym to convince it to gain muscles, consistently eat right to either gain or lose weight, and put in the time for cardio work to gain heart and lung fitness. If you don't, or don't do it consistently, your body will not change.
For guys trying to gain weight, putting in that effort to change is key. And these two articles over on Chaos & Pain round up a few ways to put on weight. Some of them are flat-out crazy, but they all point in the direction you want to go - more reps of fork-to-mouth, consistently, and steadily. Eating like it's homework.
If you are trying to lose weight, the articles are still informative. If you daily diet looks more like these bulking plans than a lean protein + veggies + healthy mix of fats . . . you know what you need to fix!
Again, I'll reiterate the warning - there is an 18 & Up consent button to click for a reason on C&P. Expect gratuitous nudity and curse words all over the place. But the advice is smart and well supported.