There are two main types of mortgage refinance — and they serve completely different purposes. Here's how each works and when to use them.