And this is one of the main reasons to buy your own food - you have a choice of what to buy! While eating out, your choice is much smaller.
You pay for some extras you may not like but you cannot remove it from the menu. Even if you can - would it affect the price? I doubt so.
Composing my own meal gives me the flexibility of choosing only the things I like + saving money.
On the top of that, the nice extras like tea/coffee/dessert/fruits come with increased margins.
Especially fruits due to their short shelf life in cut form.
Let's look at the following example; though it does not involve the restaurant prices, I still think it is representative.
In IGA (a Canadian grocery chain) a fruit salad comes for $1.30 / 100 G. A mini watermelon is $5 each, and its weight is ~2.72 kg (6lb) with 70% of it being edible. This gives us the cost of $0.26 / 100 g.
The fruit salad margin is like 500% ??? Isn't it crazy. Of course, there are other fruits in the salad but the one can easily satisfy their sweet tooth with eating one fruit instead of eating many.
(the prices are in Canadian dollars)