For example lets say you buy a house for $250k and pay $50k down, taking a 30 year 6% mortgage. Your monthly payment would be $1199.10.
Then you move in 5 years, selling the house for $250k and buying a new house for $250k. At that time you still owe $186k on your mortgage and have paid $59k interest. You are left with $64k net after paying off the mortgage, and use that as a down payment on the new house. You take out a $186k 30 year mortgage at 6%.
Your monthly payment on the new mortgage is $1115.81. But instead of paying that, continue to pay $1199.10, the payment on your original $200k mortgage. That extra ~$75/month goes toward principle.
Move again in 5 years, again selling for $250k and buying for $250k. You owe $167k, so net $83k which goes to the down payment on the new house. So this time you take out a $167k 30 year 6% loan. The payment would be $1001.25, but keep paying $1199.10.
Say you keep moving every 5 years and keep selling for $250k and buying for $250k, putting the net after each sale into the down payment for the next house, taking a 30 year 6% loan, and making monthly payments of $1199.10.
30 years after you bought the first house as you come to the end of 5 years in house #6 you will have just paid off mortgage #6 and so you end up in a fully paid off home 30 years after you started just like you would have had you stayed in the original house for 30 years. You've also paid the same total in principle and interest that you would have if you had stayed put.