A mortgage or loan is exactly the same. The interest is always calculated on the remaining balance at the time of payment. Basically, a 5% loan or mortgage for a period of 5 years will cost you the same if you respect the payment due dates. In other words, using your car loan example, if this were a mortgage under the same interest rate and lenght (5 years) you would pay exactly the same amount in interest for both.
The reason why a mortgage appears to be more expensive is simply because the maturity date is much further away. Mortgages extend to 15, 20 , 30 years, so the time needed to pay your principal is longer and reflects on the monthly payment amount. It appears and does cost more because you agree to give less each month on the principal since you will extend this to a long period of time, paying interest on a longer period of time.
Here are some numbers for you.....
Loan 1: $20,000, 5%, 5 years, total paid (22,645.20) interest paid (2645.20) payment (377.42)
Loan 2: $20,000, 5%, 15 years, total paid (28,468.80), interest paid (8468.80) payment (158.16)
Notice how your payment is less for the longer loan. It takes in account the lenght of time you agree to pay back. You pay more interest because you finance for a longer period of time.