Fed's balance sheet expansion with agency MBS reduced risks in liquidity, market depth and optionality/convexity this is a crucial point to understand - it wasn't just the Fed buying agency MBS, but the explicit government guarantee that accompanied it thus, the yields fell
raising yields means lower incentives to re-finance mortgages which reduces the amount of pre-payments thus, the duration increases when yields are raising - so even a higher price decrease
the duration formula for MBS assumes for some pre-payments if those happen at a smaller rate - the duration increases