Refinancing

Why do I need an appraisal and how does it effect the process of buying or refinancing a home?