The simplest analogy to picture how the CB works is a very basic double entry bookkeeping. What goes in and what goes out are being balanced. For every debit, there is a credit, and vice versa.
We call it 'open market operations'. What happens is that the CB purchases assets. They pay for it with money. The seller of the asset now has money. The CB now has an asset. The expanded money in the system didn't 'come out of nowhere', which is why it's not by itself inflationary.
The asset most commonly used is that nation's treasury bonds. But nothing forces that to be true. And the CB can purchase whatever assets it wants. Though different nations may have laws restricting that. It could be the bonds of a different nation, it could be lower level government bonds, it could be commercial bonds. It doesn't really matter, except to say that in general CBs buy the safest asset that's on the market. If the CB wants to tighten the money supply, they'll turn that around and sell bonds and take in cash.
When the CB issues a buy or sell order, it will happen. There's no place for the markets to refuse the CBs actions. Banks hold very large quantities of bonds, particularly safe government bonds. The CB is the primary regulator of those banks. If the CB says 'sell me your bonds', that transaction happens. Immediately. No questions asked.
So for all that the term 'printing money' is thrown around a lot, technically that's not what's happening. It's the swap of one asset, bonds, for another asset, cash. Or the digital equivalent of cash.
When governments 'print money', the CB generally isn't really involved in that. That's what happens when a government actually does print money, and pays its bills with that printed money, instead of raising revenue through taxes or borrowing. So as long as all the government spending is coming out of revenue or borrowing, it's not technically 'printing money', and there's little to no inflationary pressure as a result. Again, the American Revolution and Civil War examples hold. As does Zimbabwe.