For soda I am under the impression that the cost is really almost all in the packaging, transport, and display. Volume of product is really immaterial. Same with bottled water of course.
Marketing factors seems to be more of an issue for milk. Besides the loss leader issue there is the simple fact that people who buy half gallons may not compare prices to the gallon container or even be price sensitive when it comes to milk. They are perhaps more often a single person who is just grabbing the container the size they want and throwing it in the cart. Gallon milk purchasers OTOH are more likely very price sensitive: they buy a gallon a week or more for their family as a regular purchase and know what other stores sell it for.
I remember the same sort of thing for antihistamines: Benadryl allergy was in a bigger container for less than Benadryl for colds and cost less. Both were the exact same Benadryl - diphenhydramine same exact dose. The reason: someone going to the drug store with a cold was going to pick the brand name labelled for colds and snuffle his way home, they could stick it to him and he wouldn’t care, heck, he probably wouldn’t even finish the bottle anyway, but an allergy sufferer bought the product regularly and cared about price. Too high and they’d go generic brand.
And often Excedrin Migraine is priced higher than a larger container of Excedrin Extra Strength; they are the same exact product.
Tonight I saw a large can of veggies of some type for .85, and then noticed they sell the smaller size for .85 as well. Same brand, half the product, same price.
Milk dates are generally very accurate. Put a thermometer in your refrigerator. Your fridge should be set to between 35 and 39 deg. F. If you can’t set it that low and you can’t get it repaired right away, store the milk in the back where it’s usually the coldest.
The doors are usually the warmest place.