When gas prices rise, all gas stations immediately raise their prices as well, and then they slowly lower prices pennies at a time while competition slow incentivizes them to do so. Their customers are often more interested in convenience than in pinching the maximum amount of pennies which is what keeps customer choice and market forces from immediately driving all gas stations to the lowest possible price.
It's the same with groceries. The company gets an excuse, immediately raise grocery prices, and then slowly, oh so slowly, lowers prices, but only if the market demands it, only if people are willing to drive across town to another grocery store.
We'll either need regulation, or we'll need a way for customers to utilize the same ruthless optimization algorithms. Perhaps as online shopping continues to grow it will become more common to tell an algorithm (or an AI!) that you're getting low on canned beans and the algorithm will ruthlessly monitor prices and find the best deal within a given time frame.
Stores may not want it to be easy for customers to optimize this way, and they might make it difficult for algorithms to buy and sell on behalf of the customer. One would hope that competition would reward a company that makes it easy for customers, but competition between companies is half-assed these days and there is very little ability for new companies to enter the market and stir things up.