How does the loop know which post to view?

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