From a US perspective at least, you are right but also wrong. Like yes, it's cheaper to buy raw potatoes and dried beans and cook healthy food vs. ultra-processed "junk food." However, when most people attempt to eat healthy they do not opt for dried beans and potatoes every day. There is a huge time cost to preparing those ingredients.
And anecdotally, when I am eating healthier I am opting for a larger range of ingredients. Probably to keep my mouth interested as I am not getting the food that's been engineered to be perfect to my palate. While potatoes and beans are in my diet, I am also opting for a lot of vegetables that are more expensive, paying more for fresh herbs and interesting spices. I am almost always buying canned beans, sauces, and other foods with some processing to speed up prep time.
I think your analysis suffers from comparing processed food engineered to taste great to the blandest, driest raw ingredients. Factoring in the time and secondary ingredients to make those raw ingredients taste great adds a lot of cost. Add in the cost of more varied ingredients bc very few people want to eat beans, potatoes, rice, and bland chicken every day. And further, you're missing the savings processed foods add by being shelf stable. They can sit on a shelf or in a freezer for months or years vs. fresh produce with a much shorter lifespan.
So yes you can eat very cheap and very healthy, the vast majority of people will loathe that life over time. You can eat kind of cheap, very healthy, with a limited number of ingredients and have things taste great if you have a LOT of time to devote to cooking, this will still not satisfy many.