Typically, the commission to the buyer's agent is paid at closing out of the sales price (sellers proceeds) using money brought to the closing by the buyer, so who is actually paying the commission can be open to debate. The seller agrees to pay a commission to a listing agent, who offers part of that commission to the agent working with the buyer. The norm for many years was for the buyer's agent to accept whatever the listing agent offered rather than agree up front with their client (the buyer) what the agent's compensation will be. This can lead to extreme conflicts of interest for the buyer's agent if, for instance, the buyer is trying to decide between 2 properties offering different commission levels (say one offering 2.5%, the other 3%) and is looking to their agent for guidance.
It is now becoming more common for buyer's agents to negotiate their fee with the buyer and if the fee offered by the seller is less than the fee agreed upon, the buyer may have to pay the difference out of pocket. If the fee offered by the seller is more than the fee agreed upon, the buyer's agent should rebate the difference to the buyer, but many buyer agency agreements allow the agent to keep any overage, which fails to resolve the conflict of interest. My policy is to rebate the difference. I also offer programs where buyers can pay by the hour and get the entire commission rebated, or pay a retainer and have the amount due at closing substantially reduced and thus the rebate substantially increased. It is very important for buyers to understand how and how much their agent is paid and what the agent's incentives are in regards to compensation. Be wary of any buyer's agents who promote their services as free because they are paid by the seller. If the seller did not have to pay the buyer's agent, they could sell for less and net the same, so the buyer's agent fee is ceratinly not free to the buyer, just built in to the sales price. Nobody works for free and that agent is more interested in promoting their own self interest than in providing the buyer true client level services.