As soon as you post a question on Stack Overflow, in 5-10 seconds it starts to appear on Google Search Results. How that works? Is that the result of a very high page rank or there is some kind of alliance between Google and Stack Overflow? If you don't believe, you can try it to make sure.
I think the question is how they rank not just appear.
It says here that:
"The Golden Rule of SEO: Content is King" is the first thing to consider. It's quite simple: have good content. That's the primary reason Stack Overflow has a chance to rank at Google, simply because of how page ranking works.
Websites that have no optimization or guidelines concerns whatsoever but got nice stuff have a great chance of ranking high, because there will be people linking to good content. And most sites trying to do SEO without content won't rank well because nobody will link to them.
With that been said, Stack Overflow does a lot of work from a long time ago to keep clean HTML code.
One good example is how rel='canonical' is applied in here to keep search engines away from linking to duplicate content. For instance, let's get this page source:
<link rel="canonical" href="https://meta.stackexchange.com/questions/14056/seo-in-stackoverflow">
That is an optimization that will not help to directly rank in the search engine, but it will make the results the engine can find much more relevant and through that it might generate more links (from people who found what they were looking for) to the good content it already have, thus actually indirectly improving its rank.
When something appears in Google in seconds, it is generally because there is something notifying Google about this new content. http://pingomatic.com/ is a service that can be used for this purpose. WordPress integrates with it by default which allows blogs powered by WordPress to get listed in Google very quickly.