Google Analytics works with a 'page tag', a hidden snippet of JavaScript code (Google Analytics Tracking Code) that the user adds onto every page of his or her website. Concerning Google Analytics, the largest potential impact on data accuracy comes from users deleting or blocking cookies. Alexa actually uses a toolbar to measure website statistics. Once someone installed it, the toolbar collects data on browsing behavior. There can be some controversy over how representative Alexa's user base is of typical Internet behavior. (From source)
Simplified version: Google Analytics gives you accurate data, tracking your visitors. Alexa only guess how many visitors you had based upon the small percentage of people who have the toolbar installed. Keep in mind that google analytics is your golden tool!
It sends url of each page you visit to alexa along with some other information (referral page, page view duration etc.). Some antivirus software mark their toolbar as spyware but don't worry it isn't spyware (because you agreed to send that data to them)
I've installed alexa toolbar once but slowed down my pc and their code only work if you are a premium member. Which is why google will always come on top even if you including yahoo in the mix
Alexa Ranking analyzes the traffic of millions of Internet users to create specific traffic rankings based on the popularity of a website. This is one of the reasons that makes alexa different.