After plugins and theme functions are loaded, WordPress parses the incoming request into query variables, by going through the list of rewrite rules to find a pattern that matches the request.
There are a number of default rules for the built in types- pages, various archives, single views, pagination, feeds. You can add your own rules or endpoints manually, or register new content types which can auto-generate all those rules for your custom content.
Once the request is converted to query variables, the query is run. In many cases, the results of the query are what determine which template gets loaded.
Then of course the template is loaded, and everything is good.
So that said, there are a number of actions and filters available to let you modify things at every step. To see a more detailed view of the process and what some of those things are, have a look at the Action Reference.
The simplest and most common method is the pre_get_posts action. This exposes the query variables and lets you modify things before the query is run. See WP_Query for a reference of query vars.
If that doesn't satisfy your needs, have a look at the request filter, which allows more radical query manipulation, as it runs directly after query var extraction, before WordPress has made any decisions about the type of request that's happening.