What is the loss to the bank if the loan is repaid before time? Why do banks charge prepayment penalties?

Many times people resort to prepayment to get rid of the loan EMI. Whenever they get a lump sum amount from somewhere, they want to close the loan with that amount. But banks charge prepayment penalty on some loans. The bank benefits if the amount along with interest is received before time, then why do they charge prepayment charge?
Nowadays many types of loans like home loan, car loan or personal loan etc. are available from the bank. If you take a loan, then it has to be repaid within a fixed period. For this, EMI has to be paid every month. After a time, EMI becomes a burden, in such a situation the borrower wants to get rid of this loan as soon as possible. Prepayment is the way to close the loan on time.
Whenever a person gets a lump sum amount from somewhere, he thinks of closing the loan by prepaying it. Through prepayment, you can either reduce the principal amount by paying a part of the loan, or you can close the loan by paying the entire amount in one go. If you return the entire amount to the bank, then your account with the bank is over, then why do banks charge a penalty on prepayment? Have you ever thought about this?
Know why banks charge a loan prepayment penalty.
When you repay your loan by prepaying, you feel that you are doing a good thing, but from the bank's point of view, it is a huge loss for it. The calculation of how much interest will be charged on the loan depends on the loan tenure of the borrower and the EMI is prepared accordingly. But if you choose the option of prepayment in the middle of the tenure, then the bank is not able to charge you the interest that it could have charged for the entire tenure. In such a situation, the bank suffers a huge loss because banks earn a lot from the interest on the loan. To make up for this loss, banks charge loan prepayment penalty on the borrower. The matter of prepayment penalty is included in the terms of the loan. Some lenders charge fixed penalty, while some charge on percentage basis. Therefore, whenever you take a loan, understand its terms well.
Prepayment charge is not levied on all loans
Prepayment charge is not levied on all types of loans. If you take a home loan on fixed rate, then the bank can charge you a prepayment charge on its prepayment. But prepayment charge is not levied on floating rate loans. On the other hand, if you repay the personal loan before time, then most banks charge prepayment charge on this too. Banks have different terms and conditions for this.
Do this calculation before deciding on prepayment
To understand whether the decision of loan prepayment is beneficial for you or not, first see whether the loan terms mention prepayment penalty or not. If not, then you can take this decision. On the other hand, if Prepayment Penalty is being charged on the loan, then you should do a calculation. Only after this, reach a conclusion.
First see how much penalty will be charged for repaying the loan beforehand. After this, calculate the total interest to be paid on your remaining loan. After this, subtract the penalty from the interest. After this, decide according to the answer you get. If you are saving a lot of interest even after paying the penalty, then you can take the decision of loan prepayment. If the matter is equal, then you will have only one benefit of loan prepayment, you can get rid of EMI. Take a decision after looking at your situation. On the other hand, if you feel that the answer is negative, then you will only incur a loss due to prepayment, in such a situation it will be wise to repay the loan in its entire tenure.