On the Google and Yahoo search pages, the URLs of the 10 search result links actually point to google.com or yahoo.com. The URLs have extra arguments that allow google.com
It's hard to read the source, but you will see that in fact the URLs (in the tags) are the correct destination URLs, which is why the browser's status bar shows the correct URL (instead of the tracking link that it redirects you through when you actually click). There is then some
onclick
JavaScript that can then intercept the clicks before the browser's default action (following the link) can take place.