When Fed purchases securities from a bank (depository institution) the Fed pays with reserve balances, which are liabilities of the Fed and assets of the bank sector, so the transaction would be recorded as follows. On Fed balance sheet the Fed debits securities held as assets for an increase and Fed credits reserve balances due to bank sector for an increase. This expands the Fed balance sheet. On the Bank sector balance sheet there is a debit of reserve balance assets for an increase and a credit of securities held as assets for a decrease. This does not expand the Bank sector balance sheet. The initial result would be to increase base money, in the form of reserve balances, when Fed purchases securities from the Bank sector. In theory banks can sell securities to get reserve balances so securities and reserve balances are the liquidity cushion of the Bank sector. Banks would not sell all their securities to the Fed unless interest on excess reserves exceeds the interest earned on the Bank sector securities portfolio.
When Fed purchases securites from a nonbank unit the aggregate Bank sector clears payment between Fed and their nonbank customers. So Fed still debits securities on its balance sheet for an increase and credits reserve balances for an increase. Bank sector debits reserve balances for an increase and credits deposit liabilities due to the nonbank customer for an increase. The nonbanks that sell securities to Fed in open market operations (OMO) debit deposit assets for an increase and credit securities assets for a decrease.
Reserve balances are a component of base money or so-called M0 money supply. Some types of deposit liabilities are components of M1/M2 money supply. So when Fed does OMO operations with Bank sector as counter-party this would increase or decrease base money. When Fed does OMO with a nonbank this would either increase or decrease both base money and M1/M2 initially. However the aggregate Bank sector actively manages its mix of deposits, other liabilities, and equity so M1/M2 money "migrates" due to liabilities and equity management. Fed has no direct control over M1/M2 because the Bank sector interacts with nonbanks and the net result of Fed doing its thing and Banks doing their thing is the M1/M2 level at any point in time.
Banks tend to issue and expand credit (assets held) which tends to increase M1/M2 initially. But then bank sector liability management and nonbank portfolio allocation decisions mean no one is in control of the M1/M2 money supply levels.
Fed exists to kill rampant inflation and/or attempt to cause inflation to prevent a rapid debt deflation. This effort is more about the decisions being made in the credit system, the conditions in money and credit markets, than it is about the level of the money supply at any given time. During periods when financial markets operate in a predictable mode the money supply may correlate well with Fed policy. However the elastic money supply is a residual of all the transactions on the aggregate bank balance sheet which are driven by the Fed credit policy, the aggregate Bank sector credit policies, and the portfolio allocations of the nonbank sector.