You end up with the cheapest calories being lightly processed grains like rice and flour, then you end up with more processed grains like white bread and ramen, then move to things like peanut butter, before hitting junk food. The point is that the cheapest calories aren’t exactly healthy.
The produce aisle tends to be pretty expensive per calorie, potatoes excepted, since veggies aren’t calorically dense, and are sold mostly by weight.
I challenge you to find any junk food that comes even close to that kind of caloric density per dollar. The cheapest junk food has a tenth of the calories per dollar than a bag of rice from Costco (4-5k calories per dollar), at best.
The problem is that the cheap stuff takes a little effort to make tasty compared to the hyper-palatable junk food. The whole "junk food is cheaper than whole foods per calorie" is nonsense.
The point is, if money is tight, which invariably means that time is tight, people don't have time to cook dried pinto beans, or make bread for EVERY meal where the prep time is roughly 12 hours. Add into that, even knowing how to cook is a skill. An all bread and pinto diet is likely to take more time than most people have, and not yield a great health outcome anyway.
If you look at it as categories, the junk food, and processed food aisles are where you are going to on average get your dollar to go furthest.
The whole point of the "myth" is that it is FAR more efficient and cheaper to get everyone enough calories with food from the junk aisle. The origins I believe come from a cooking show where the budget and time were limited. Professional chefs gave up.
Here's the challenge: you need to serve a meal to 4 people (2,500 caloriesp) you have $10 and 1 hour including shopping and cooking. I can think of half a dozen meals that come from processed foods where that is possible, but doing that with fresh foods is HARD.
If you want to go the pure science route, here's a peer review study from the NIH showing that in many places on earth, healthy food is provably more expensive https://www.ncbi.nlm.nih.gov/pmc/articles/PMC6825829/
See: potatoes. They're basically pure calories and they're several times cheaper than any junk food. Junk food is the most expensive food no matter how you slice it. The only metric by which junk food might win is in the lazy glutton category; if somebody is too lazy to put a potato in their oven 45 minutes before their meal, then a bag of potato chips has an advantage. But in no other sense is junk food more efficient. And even for lazy people, there are plenty of cheap as dirt veggies that require less cooking or no cooking at all. A bag of apples is a very cheap way of getting a sugar rush without any food prep, but fat people would rather spend that money on several gallons of cola a week.