That's because www technically is a subdomain of the domain.com website. This harkens back to the days when servers couldn't handle HTTP, FTP, POP, and SMTP all on the same server (this is why you see ftp.domain.com used for FTP purposes but it also really just points to domain.com. The same for pop.domain.com, smptp.domain.com, and, more common nowadays, mail.domain.com). However, since servers are obviously more powerful, most websites don't use the www as a subdomain and simply have it point to the domain.com content.
You're able to type in www.domain.com because an alias was automatically created in your DNS records for you by your webhost. Most hosts do this since it's very, very common to want the www subdomain to point to the domain.com website.