When the broker is in a listing agreement with a seller, the seller pays the broker a fee (a commission) for services rendered.
When the broker is working with a buyer purchasing an unlisted property -- a For Sale By Owner -- and the seller won't pay a fee, the buyer will be responsible for paying it. Sometimes buyer and seller agree to split the broker's fee. Be sure about who will pay the fee before entering into a contract. Your Realtor will explain this to you.