Your assumption isn't quite right.
Firstly, there's not a one-to-one relationship between the amount the bank has borrowed, and the amount it has lent out at any time. Using the concept of "fractional reserve banking" the bank creates new money out of nowhere when it creates a loan account/mortgage. To meet banking regulations, it only needs to take deposits from savers on a smaller amount to stay within its regulated reserve or capital requirement levels.
That's how banks create new credit virtually out of thin air, which then enables people to get credit to buy stuff, especially assets like houses, which increases what people are willing and able to offer, for a relatively fixed base of those assets, and hence balloons debt in the economy.
Banks are constantly tuning their reserves by borrowing and lending between each other, and with the central bank. What is clear is that the interest rate they charge you is always higher tan the interbank rates - that's how they cover their credit risk (ie you might stop paying your mortgage) and of course generate profit.
To your specific question: when the bank imposes higher interest rates on mortgage holders, it is pocketing the extra interest you have to pay. But against that the bank is likely to be having to pay higher rates to borrow (part of) that back on the interbank markets if the base rate has risen, and also its risk levels may have changed so it might anticipate higher mortgage defaults.
I'm not a banker or an economist so if there's one on here maybe they can give a better answer.