Ask an agent - and they will say contact the agent first. They don't want a mortgage broker to recommend their preferred agent and chance losing the business.
Ask a lender - and they will say contact the lender first. They don't want a real estate agent to recommend their preferred lender chance losing out on the business.
The truth is - it really doesn't matter all that much who you technically "approach" first. The bottom line is - before you start actively looking, you should have all of the financials figured out.
You should both:
1. Know how much you can comfortably afford. This means factoring in anything that is going to make a difference in your monthly payment. Interest rate, mortgage insurance if applicable, taxes, and purchase price all play a role in this.
2. Have a pre-approval letter. Most, if not all, sellers are going to require this with any offer you make today. Without it, your offer will likely simply get ignored. This is especially true with REO properties.
Above and beyond all this - educate yourself. There is a wealth of information available these days, both online, and likely through consumer groups in your area, that can educate you on both the financing, and purchase processes. A educated buyer who takes it upon themselves to do a little due dilligence of their own is almost always going to get a better overall deal at the end of the day.
Hope this helps!