Don't worry about what is in the source code of your themes templates. What you need to look at is the source code of your sites page when it's displayed. Google will index that HTML code only, nothing more and nothing less.
As for how WP works, it gets the content from the DB for the page that it's on, runs it thorugh a series of filters to format the HTML, adds in any shrotcodes or other extras, and then outputs it to the browser. Of course that's a pretty simplified version of it, but unless you really want to go digging around in the source code, that's all you need to know.