“Does this mean that if I make a website called www.mywebsite.com, there is a singular device inside the domain example.com which has the hostname called www? And does this mean that if this singular device with the label www goes offline or whatever reason, all my users would not be able to reach www.example.com?”
Yes. That is correct.
I think part of your confusion is you are mixing up domain/hostname info with the actual destination IP addresses connected to that.
All DNS entries like example.com and www are are alias that point to IP addresses. How you assign those IP addresses and where they go to is up to you.
So you can have a structure like this:
www.example.com: Points to one IP address like 1.2.3.4.
example.com: Points to another IP address like 5.6.7.8.
That means that each domain name is a different server, device, etc…
But in many cases for simple websites the architecture is like this:
www.example.com: Points to one IP address like 1.2.3.4.
example.com: Points to also points to 1.2.3.4.
The way this works is you can configure your Webservers — typically something like Apache — to respond to both hostnames. So www.example.com and example.com serves the same exact website.
But Apache can also be configured to handle virtual host configurations. So the one server at 1.2.3.4 can serve two different websites to www.example.com and example.com.
So this is all about conventions and use of DNS language. The reality is a place like Google doesn’t just have one IP address and one server for all their services. So if mail.google.com goes down, the main google.com is never affected.
Just always remember that hostnames, domains and subdomains are not codependent to whatever their destination IP address is unless you intentionally architect a system like that.
In my example of www.example.com and example.com both pointing to 1.2.3.4 many basic websites work like that purely to give the end user the convenience of getting the same content at both domain names.