Mortgages generally contain what is called a “due on sale” clause. This clause gives the mortgage company the right to demand immediate payment on the note if the borrower transfers any part of their ownership in the property to someone else. Thus, when someone goes to sell their property, the title company will not issue a clean title commitment to the buyer unless they also hold back enough money from the proceeds of the sale to pay off the old mortgage and obtain a release.
At one time one of the major mortgage lenders was in the process of developing a “take your mortgage with you” program such as what you describe in your question. That lender, however, was acquired by another company and nothing seems to have materialized from its plan for that program.