Inflation on a macro level is explained by price discovery along the supply-demand curve of money supply. However, when you apply this to supply-demand of specific items, this relationship on the macro level is not so obvious because price distortions will exist for bottlenecked items with supply constraints. This is how the CPI of core inflation can be manipulated to make it look like inflation is way lower than it actually is on the macro level. It is also the reason why sanctioned items can distort inflation for those sanctioned items due to their supply constraint. However, when you consider inflation on a macro level, as long as the entire economy is not able to be sanctioned into oblivion like Cuba, Venezuela, Iran or North Korea, it's macro inflation that is important.
In the case of Russia, if you compare the options of printing money out of nothing vs saving trade surpluses as balance sheet surpluses realized from economic activity, the main difference is the source of the Rubles. When currency is printed, it comes out of nothing, so it's direct result is inflation on the macro level commensurate with the inflation of the money supply because there was no change in the size of economy relative to the money supply. The Rubles coming from the gas and oil trade is the manifestation of economic activity from the infrastructure, extraction, labor and transportation of said oil and gas that was all initially paid for in Rubles before being exported to Europe. That oil and gas was paid for in US Dollars and Euros which are exchanged for Rubles on the forex market after the physical exchange of the oil and gas. In other words, the Rubles make a circular route with the end result being an account surplus of Rubles without printing Rubles and incurring macro inflation. This is no different than a worker earning their salary and saving it in a bank account for a rainy day. The inflation you refer to is not from macro inflation as I just described but from microeconomic price distortions caused by sanctions. So, for Russia to save Rubles in their current account for a rainy day, it has money to spend when it needs to spend it instead of being forced to print money when it needs to spend it which would create macro inflation.
There is nuance to this equation. The less self-sufficient a country is, the greater the potential for distortions to macro inflation. The level of self-sufficiency plays a huge role in how much foreign exchange reserves are needed in addition to needing foreign currencies to stabilize or fight currency attacks. However, this is another discussion.