Broker has several meanings in different situations.
Most agents work under a broker. Some agents are brokers as well, either working for themselves or under another broker.
In the mortgage industry, broker usually refers to a company or individual that does not lend the money for the loans themselves, but broker loans to larger lenders or investors.
As a normal definition, a broker is anyone who acts as an agent, bringing two parties together for any type of transaction and earns a fee for doing so.