In order to prepare a meal, you need to be able to afford ingredients, have the required skills, and have the time/energy to cook. So yes, it is cheaper to prepare your own meal, but if for example you're working three jobs to make rent while raising a child, you're going to have difficulty finding the time or energy required for cooking. Doubly true if you don't already know how to cook.
There's also people without access to a kitchen. If you have to rely on other people to cook for you, you're extremely limited in options and as a result you'll likely have to spend more money on fast food and takeout.
Another thing to think about: it's cheaper to grow your own food than to buy it. Most of us don't grow our own food - probably because we lack time, knowledge, or land.
Another aspect to this is our society and culture. Eating out is a special treat, a privileged event that's deep in our subconscious. Have grandparents that take you to a favorite spot? A friend that loves to eat at this one certain place. Just want to have a more relaxing day because of over-stressing? The food joint is our new spa.
I don't enjoy eating out so it's easy for me to avoid it. But, my family has the average addiction and my partner comes from a household that would eat out at any opportunity (I've seen them do all 3 meals in a day when visiting once). You don't realize the amount of money being spent on advertising till you're trying to get someone to cut back. Newspapers, online ads, roadside signs, we even get "coupons" in the mail it feels like several times a week. Kid's programming, sponsored school events from nearby food chains, high schools will have a domino's in it before they get a robotics lab.
It's crazy we allow any of this, we know from past cigarette legislation what this kind of inundation can do to people psychologically.
I resent the implication that Greggs and Subway are equivalent. Subway is the only place where they ask you 500 questions when you ask for a cheese sandwich.
Every time a thread like this pops up the sentiment is that their food is awful and you're an idiot for eating there - so I'd say for at least a decade or two.