Shared web hosting is also for the case of different people, each with one or many different domain names, in addition to the cases of one or more different sub-domains.
For example, I have about 30 domain names on a single web hosting account. The files for my "First" domain name are located in the root of my "public_html" folder. This folder is in my "home" directory, so something like: ".../.../username/home/public_html".
And, in the root of this folder are folders for each sub-domain of my "First" domain name. Lets say my "First" domain name is "example.com", and I have some sub-domains. The files will be organized like this:
"example.com" --> ".../username/home/public_html"
"a.example.com" --> ".../username/home/public_html/a"
"b.example.com" --> ".../username/home/public_html/b"
"c.example.com" --> ".../username/home/public_html/c"
Plus, there is another folder in public_html for each of my other additional domain names (referred to as "add-on" domains in my hosting).
"domain2.com" --> ".../username/home/public_html/somefolder"
"domain3.com" --> ".../username/home/public_html/otherfolder"
"a.domain2.com" --> ".../username/home/public_html/somefolder/a"
"b.domain3.com" --> ".../username/home/public_html/otherfolder/b"
Plus, many other people (perhaps dozens of people), each having a different "username", all have hosting accounts on the same computer, and each of these other users may have one or many domains and sub-domains, with their files organized in a similar fashion.
All of these users, including me, all share the same IP address. If I want, I could pay extra to have one or more unique IP addresses for my domains.
Originally, at least in concept, I believe the internet was setup with each domain name to have a different IP address. I think around the time of HTTP/1.1 this was changed to allow multiple domain names to share a single IP address. This was done then because of the concern of running out of IP addresses.