It's not done for either of those reasons. It's done to remove the decision point around believing you need to comparison shop on impulse purchases, by pretending that a price will be matched later should you find one. However, the terms are usually such that they will never be honoured.
Many groceries near me do price matching, but indeed they limit it to a select few competitors (the big 5's brands in the same price market)