In the past, they couldn't get away with it. We used to have competition. Competition slowly changed to oligopoly over the years but companies were still applying lessons learned in the distant past that raising prices would drive away customers. But once they learned that they now can get away with raising prices...
The prisoner's dilemma of price discovery for corporations has shifted from the competitive mode to collusion mode thanks to the perturbation of COVID and inflation fear.
The more people are aware of the fact that inflation is soaring according to the news, the more people find it expected that they see high prices at grocery stores, the more companies can raise prices.