CPI does weight items by based on spending patterns (although the details of how to determine this weight are complicated and the main reason there are multiple inflation indecises).
The 2022 CPI has a 0.178% contribution from the price of milk, and a 45.065% contribution from the price of Housing. Housing itself is subdived into several subcategories. Notably, neither the purchase price of a house nor the typical mortgage are included. Instead, homeowners cost of shelter is covered by “owner’s equivelent rent” which attempts to answer what the owner would be paying if they had to rent the house they are living in.
All models are wrong, but some are useful. Thinking of evolved features as having a purpose is wrong, but it is also incredibly useful.
Why do we have eyes? In some sense, there is no reason, just a sequence of random coincidences, combined with a slightly non-randon bias refered to as “survival of the fittest” (itself an incorrect model).
However, saying that we have eyes to see has incredible explanatory power, which makes it a useful model. Just like Newton’s law of Universal gravity. We’ve known it that is wrong for a century at this point, but most of the time still talk as if it’s true, because it is useful.