Hello,
Simply put, Google provides you with AdSense HTML ad code to place on the web pages on which you want to display AdWords ads. Then, they take care of the rest by leveraging award-winning and proprietary Google search and page-ranking technologies to deliver relevant AdWords ads to those content pages.
Google goes beyond simple keyword matching to understand the context and content of web pages. Based on a sophisticated algorithm that includes such factors as keyword analysis, word frequency, font size, and the overall link structure of the web, they know what a page is about, and can precisely match Google ads to each page.