The code is in admin/register.php in your Moodle ... it's a simple count of the records in the course table (minus 1). These records are deleted when courses are deleted, so it's a fairly true indication of the number of courses on a site (at the time they last registered).
However many of the courses may be hidden from view by the general public (eg they could be archives or private courses etc)
Moodle community sites
moodle.org stats
This discussion has been locked so you can no longer reply to it.