Did you know that at JFK it is possible to shell out $6 for a pack of dry, grocery-store ramen? 🙄
There are soooo many good reasons to bring your own food onboard to eat, instead of succumbing and paying three times more for what something should be. Food does technically count toward the carry-on limit, though we have never been called out during security for the past two million miles we have flown.
In an ideal world, we'd be able to squeeze our lunch into our carry on, but every inch of space is precious. There's a ton of anecdotal evidence out there as well that having a carry on, personal item and lunch bag isn't enough to get in trouble—airports are busy places.
However, TSA are well within their rights to call you out on it, though, honestly, they aren't vicious monsters deep down inside. (Our lunch bag is pretty conspicuous.)
Besides, the worst case scenario is chunking it in the trash, and then, well, having to go buy some overpriced airport food.
Since we're on the topic, liquid food items like soups and sauces over 3.5 ounces (100 mL) have always made it past fine from our experience. However, they are generally not recommended more for the potential-for-things-to-go-south-mess factor than for the security factor (also personal experience).
In general, airline food is composed a little bit differently from food cooked on the ground. Our tastebuds literally process things differently 30,000 feet up in the air—so airlines often need to concentrate and double up the amount of sodium and umami in order for it to taste anywhere similar than it would taste on the ground.
Meaning it's also not the poster child for health, and opting for another option is probably the best choice.
Like most things, it is not a perfect answer since the reality doesn't match the rules, but hopefully, it at least somewhat answers the question.