The best way to avoid this is to get pre-approved for a mortgage so you know exactly how much you can afford. Usually pre-approvals are free.
Unless an agent is working as your buyer representative, they represent the seller. Many people don't realize this.
A bad mortgage can cost you thousands in taxes and interest. Consult an accountant before you choose your mortgage.
You should always have a professional inspector look at the home before buying it, otherwise you could be looking at huge repair costs later on. Read this guide to avoiding a money pit.
Get a mortgage professional to help you go over and prepare your credit file before you buy a home.