Food I think would easier to switch to a different supplier or buy a totally different one (like the alternatives I've mentioned). With oil and gas though it'll take longer to build new pipelines.
This is one reason Russia invaded - the pipelines are already built and Ukraine can use those to export their own gas that has been discovered there - in areas conveniently occupied by Russia now. That would have provided an alternative to Europe.
No. It is not easier to switch to a different supplier in case of food. You might not have noticed this, but rice production is also getting impacted from this war (Potash fertilizer which is needed for rice cultivation is in short supply, as Russia and Belarus contribute almost 40% of the global supply). And now coming to pipeline gas, there is already an "alternate" pipeline to transport Azeri gas to the Europe. But the gas production in Azerbaijan has not kept up with the expectations and the pipeline is now transporting far less volumes than it was originally designed to.