Rice, beans, and vegetables are very nutritious and cheap but they're generally boring in comparison to a bag of Cheetos or a doughnut.
When you're dirt poor, you don't have many avenues to get a quick pick-me-up feeling -- so often that comes from junk food. A $1 burger is not as good for you as $1 of veg and rice, but it gives you more momentary pleasure and activates the reward centres in your brain.
Even as you eat it, you know you could be eating something more nutritious which would be better for you in the long-run, but you still eat it. Once you do it the first time, the subsequent times become easier, especially if it's loaded with sugar and you get yourself in a high/low blood sugar cycle.
I'm not defending it, and I'm not saying people have no control over themselves, but I just wish people would have a little more compassion and understanding when they go for the "beans and veg are cheap" argument.