If you look through the bond market you will sometimes see bonds issued by the same company or agency both as callable and non-callable, the callable bonds are usually .5-1% lower even when issued on the same date.
Consumers have a tendency to pay loans back early when the bank doesn’t have any more profitable alternatives. Consumers also have a tendency to NOT pay loans back early when the bank does have more profitable alternatives.
But you know that the first situation is worse for the bank than the second situation. So they do account for this, to a degree, when they give you a loan. In theory they would be willing to give you a lower interest rate if you gave up your prepayment option. In theory. In reality? Who knows.
Demand for mortgage varies over time, regulations change. It's a long term product, banks like to know with high certainty that when someone signs up it will be X earned over a period, not maybe X minus we don't know over an unknown period.
They are in the business of capital efficiency. Lack of control makes capital less efficient, or at least more expensive to keep efficient.
Overpayments (in the UK) are often not allowed, when they are, the borrower needs to arrange it when the loan is taken, and for a fee.
Refinancing is a right, but the fine prints told borrowers at what penalty.