How many websites are there in the world?
Due to the internet do not really belong to any single person, entity or organization; it is difficult to quantify the internet. There is no central control, and therefore no single "complete list" of all the different websites. Large Internet Service Providers (ISP's) will register domains and address space, which then gets split up between other ISP's, companies, and eventually the end user. Each of these address spaces are in turn will widely used for various purposes, some of which will include hosting websites.
Not all domains are used for websites, and the owners of those domains are not at liberty to report the number of sites being hosted by their servers. In some countries, where very fast internet connections are available straight to the home, internet bravado's and business people alike, host their own servers with computers in their bedrooms. All these factors make "counting" websites a rather daunting task.
There are, however, several non-profit, and even some profit organizations dedicated in monitoring internet activities. The Internet Society (isoc.org) provides leadership for the orderly growth and development of the Internet; Internet Engineering Task force (ietf.org) is a sub-group of ISOC that researches new technologies for the Internet to allow improvement of the capabilities and functions of the Internet; The World Wide Web Consortium (w3.org) is a consortium of over 400-member organizations that set standards and develops protocols for the web. And even though there are seemingly so many "controlling entities", the vastness that is the internet is still almost immeasurable.
Who tracks these figures, and for what reason?
One of these organisations is Netcraft. The Netcraft Web Server Survey attempts to scan the internet with "spider-like" software to determine web server market share (percentage of servers running on Microsoft IIS versus Apache). Fortunately, not only does it determine what software the server is running on, it also counts the number of unique sites the software encounters. It is interesting to note on their graphs how the number of websites increased exponentially in an era where storage space has become so much more affordable, allowing massive sizes for domains, and therefore also sub-domains. As of the October 2011 survey, Netcraft received responses from 504,082,040 individual websites, around 18-million more than that of September 2011. They have a website of their own with address: http://news.netcraft.com/ containing the available information for all the various statistics related to the internet.
How are websites tracked when the go offline takes forever?
Again, because the internet is not necessarily controlled by a single entity, the websites that go offline would virtually just disappear. There is no responsibility towards the owner of a website to announce the removal of any particular site. The URL might still come up as a result in a Google search, if the website was ever submitted, but one would get an error when clicking on that particular result. Also, tracking software such as that of Netcraft would just not get a response at that particular address anymore, and that site will no longer be counted as active.