How does WP work in conjunction with a web server?

Apache only runs the index.php of WordPress, and serves static files (images, css, js etc). WP does all the rest, including parsing the request to find out what content to show the user. Apache does not (and needs not) know that there is communication with a data base in PHP, and doesn’t interact with that database itself at any point.

That’s also why you don’t necessarily need Apache in the equation, you could also use nginx or other webservers (as long as they offer a way to run php), or no external webserver at all and just use php’s internal webserver (though that’s mostly for development, idk how well this holds up in production).