These two questions are actually the same, because if one understands how search engines work, he will probably be able to get a site to the top search engines ranking.
Think about it.
Unfortunately, the answer is a complicated, dynamic and a secret one. The answer has to do with SEO - Search engines optimization. In fact, very few SEO experts, SEO consultants, SEO software and SEO companies can actually give you a perfect SEO solution.
In the next few lines I will simplify how search engines work. To understand more you must contact and pay to a SEO consultant working with a popular SEO service:
1. The search engines visit your site occasionally and index new topics on your site.
2. The search engines measure the quality and popularity of your site by the number and types of links to your site by other website.
3. According to the site topics, quality and popularity and many other parameters the search engine rank the site for each keyword searched.
Now, I guess you have a website or developing one and you want to get it to the top search engine rankings. Well, If you have money I suggest you pay to an experienced SEO consultant working for one of the top SEO companies.
Yet, if you do not have money, you can try doing it alone. But, be warned - a good SEO solution is time consuming. No matter which SEO software or SEO service you will be using, it will take you at least a couple of months to get your website to top search engines ranking.
Your first step would have to be reading more about the subject - reading about meta tags optimization services, keyword services, back links methods and organic SEO and using free SEO services like SEO toolbars and online SEO software. Good luck.