Take a look at @rdlowrey's answer to How Wordpress Generates HTML for Blog Posts
What Wordpress does -- and indeed many of the popular MVC frameworks -- is route ALL traffic to A Front Controller [wiki] script using an apache .htaccess file.
So when you are accessing any page served by a WP installation, certain functions become available to you, since it's all passing through the same "start point".
To start following the trail, open up index.php in the root directory, and see this:
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
From there, take a look at wp-blog-header.php. It's loading wp-load.php. If there's no wp-config.php, it prompts you to install. If you do have it in your directory, notice it requires wp-settings.php.
In the settings file, you'll see explicitly where your theme's functions.php file gets added into the mix around line 318 (of WP 3.8.1 at least)
// Load the functions for the active theme, for both parent and child theme if applicable.
if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
include( STYLESHEETPATH . '/functions.php' );
if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
include( TEMPLATEPATH . '/functions.php' );
}