It's the programming in the browser itself. Most browsers are programmed to keep the previous file's (page's) address, in most circumstances. However there are many exceptions when the previous page is NOT kept by the browser when it requests a new file. Do a search on "direct traffic empty referrer" or something like that to get a lot of information about this. For info on standards about how browsers are supposed to act, see a site like W3C's.
Statcounter itself doesn't have much intelligence.