EAch theme has its on index.php, page.php, style.css, etc
It is the style.css file that names the theme and that is used to select which theme is being used. You select it from your admin section under "Appearances"
Every entry is a post in WordPress, though that seems somewhat hidden to most users.... Posts are associated to one or more Categories or... you can add a Page, which is a single post that is unassociated with any categories.
As to WHICH FILE (index, page, category, archive, single, etc) is used to display the content pulled via the loop from the database, it depends upon the link or code. For example, if you set your homepage to be your blog, you are selecting (likely) the index.php file to be the file used thus its loop -- with any modifications to functions and conditional statements -- will display the requested content. On a homepage, that means it will display posts from all your categories, unless you modify the code to do something else.
If your homepage is set to a static WordPress Page (a post that isn't part of any category... ) only the content in that page is displayed. Since there's only one entry, the loop actually doesn't "loop".
Pages also have a simple mechanism to select a template (page.php is the "default" Page template; search the documentation to undertand how to create a custom Page template). Categories require a custom category-#.php file that is "found" by WordPress if it exists (where the # is the id of the category). The disadvantage of this is that it ONLY applies to THAT category (based on the exact id number). Don't ask why... I'd guess it is because categories and posts came first and Pages (and selectable and sharable Page templates) came later, after seeing the disadvantages to the existing method for categories.
Archive.php is used when requesting archived stuff; single.php is used to display a single post...
Basically, the template file used is "hierarchical" beginning with index.php. If no other files are available, then index will be used for all things.
It's not like static html files at all. The content exists in database tables and is displayed in a file pertinent to both the post type (post or Page) and the the link calling the content (eg. a custom category-x.php file if it exists or the Page template selected if the link points to a Page) and the code and layout of the file used.
And, sidebar.php and footer.php and header.php are shared by all the templates if you so desire. There's no requirement to have a separate footer or sidebar... they are simply just where you'd put common markup/code, etc that appears on all pages... generally. You can have different sidebars or footers or headers as desired but the get_header() or get_sidebar() or get_footer() function maybe wouldn't understand pointing to those... you'd use an include or require function instead.
It all comes down to understanding the big picture of the difference between how a static site provides content versus how it's done for dynamically generated content pages.