Yahoo's advertising is done through
Overture.
Google's is handled through
AdWords.
With the exception of one or two advertisers in the blue background on Google, the rest of the paying advertisers in the right column.
Yahoo's are marked as "Sponsor Results" in the top and bottom of the organic listings.
Both programs are pay-per-clcik, meaning that advertisors bid on how much they want to spend per click 0.12, 0.46, 2.35, whatever, depending on the word or phrase and the highest bidder gets first, #2 gets second, etc.
If you are considering using these services, make sure you research them both and learn all you can about the system before you spend the first dime.