Q: Why does a web site check what browser I use?
A: Because all browsers are different. Often a website will send different code to different browsers.
Q: How can a website tell?
Q: Why does Opera and others try to hide their real identities?
A: To avoid receiving crippled versions of the pages.
There is hardly any browser out there that really reports its identity. IE spoofs Netscape because Netscape was the first browser to implement certain HTML features in the early days of the web, and webmasters started blocking other browsers.
When Opera identifies itself as IE, it is in fact spoofing IE spoofing Netscape using the code name "Mozilla", so there is version and name-information of three different browsers included…
Q: Why can a website detect I'm using Opera even if it is identifying as something else?
A: Opera never completely hides its identity when spoofing another browser. This is a feature, not a bug. There are two main reasons for this:
1) If Opera completely hid its identity, it would not appear in any server logs or statistics over browser usage. No webmasters would ever bother testing their sites with it, assuming that nobody used it.
2) Detecting Opera allows webmasters to serve Opera – adapted pages. For instance, webmasters who are aware of Opera's standards-compliance can send a standards-compliant page even if Opera identifies as MSIE and would normally get IE-specific code.
Sadly, sometimes webmasters use this to detect and block Opera specifically.