It’s rare to have enough cash on hand to buy a home in full on the day of purchase, nor is it always in your best interest. In most cases you’ll need to borrow in order to buy.
A mortgage is a long-term loan for the purchase of property or land, generally lasting around 25 years. Refinancing on the other hand, is when you already have a mortgage plan and are looking to change it. You might consider refinancing if interest rates have gone down, or if you want to shorten the term of your loan. You could also refinance in order to reduce your monthly payments.