https://www.khanacademy.org/economics-finance-domain/ap-macr...
"The Fed can indeed create money "out of thin air." To be more precise, it does so with keystrokes on a computer. This was illustrated with its QE program, also known as open market operations. That's when the Fed buys an asset from a financial institution and pays for it with money it simply creates."
they provide price stability (by keeping the money supply corresponding to the demand) and they try to maximize employment (by helping the economy through providing liquidity, every central bank is the "lender of last resort" but that's for emergencies, usually they operate simply by providing forward guidance and conducting open market operations to keep the interbank interest rate close to the target rate).
don't think of them like just a bank, it's more like the Mint, combined with an expert panel that tries to smooth out the fluctuations of the economy ( https://en.wikipedia.org/wiki/Real_business-cycle_theory )
Also, as long as they don't try to get clever - like the Bank of Japan did with strategic loans ("window guidance" back in the 80s).
Printing money to keep up with economic growth is also an important function of central banks.
Deficit spending is ultimately simply financed by paying off the debt in the future via taxes. (And the growing economy and the stable but low inflation helps with this.)
I was under the impression the last 40 years of US deficit spending has been mostly financed by selling US bonds to China, Japan, etc., while counting on growth and inflation to take the edge off when they come due. And selling more bonds instead of defaulting, so the debt just keeps growing. Printing money causes inflation but not deficits or lingering debt.
I don't know though, I'm not an expert. I would appreciate any corrections or clarifications from anyone.