I think I have understood most of how to create my own themes but this one thing: How can a loop in say page.php know which page to view when it loops through all the pages on my site? If I load one of my single pages (ex. contact form) how does page.php knows that it should only load that one specific page when it loops through all of them?
Your loop on
page.php doesn't loop through all the pages on the site. It loops though all the pages returned by the main query and stored in the
$wp_query global variable, which is how all of the primary WordPress "pages" work including the post archive pages, category, tag pages, etc. For any one "page" only one page will be in the
$wp_query global so you only see one.
While the details can get complicated, what happens with a page load in WordPress is that the
WP_Query class gets instantiated fairly early and it parses the url being loaded and works out what posts to query. That information is shoved into the
wp_query global variable and is accessed by numerous bits of code thereafter (which is why you don't really ever want to alter that variable manually or via
query_posts()). It is a wildly complicated mechanism which you can see here: https://core.trac.wordpress.org/browser/tags/4.3.1/src/wp-includes/query.php#L1448
A shorter/simplified version of @s_ha_dum's answer.
Running the templates to do the actual outputting of the HTML is the last thing wordpress does. Before getting there, wordpress parers the URL and based on that it determines the specific content that will be displayed. It is not really open ended, although plugins can extend the loop to do any weird stuff, it is fully determined based on the URL.