Many mortgages come with a "tie in period", typically 1, 2, 3 or 5 years (sometimes longer) where you would pay a penalty or fee if you changed lender during this period.
With some mortgages, the tie-in period is the same length as the fixed/discounted/tracker rate period although some have tie-ins that extend beyond the "low rate" period.
It would be typical for you to have to pay a penalty if you switched Mortgage lender during this "tie in" period, typically this can be between 1 and 3% of the total loan amount. In many cases therefore a long tie-in period may not be suitable, for example if you wish to retain flexibility to re-mortgage if your circumstances changed. (Please note that moving house does not usually affect tie in periods as most lenders allow you to "port" the mortgage from one property to another)
Conversely you may wish to accept the tie in period to take advantage of a better headline rate or a better mortgage offer from the lender.