Essentially, we break down all of the possible IP addresses into classes. All class A start with 0, all class B start with 10, all class C start with 110 and all class D start with 1110. There are only a few class A networks (128), but they each support between 65,000 and 17 million hosts or something. Apple has one, but not many companies do. There are more of class B (16,00) but they can only support up to 65,000 hosts. Class D addresses are for multicast addresses, so they only have a multicast address and machines will subscribe to those addresses, and multiple machines can receive packets addressed to the same multicast address.
You have to buy these class addresses.
Classless addressing: Instead of breaking things into classes, break them up in classless ways (classless inter domain routing CIDR). So you just have slash notation which indicates which bits are network and which are host.
Hierarchical addressing is where each ISP will actually advertise to the internet core that it has the IPs of 18.104.22.168/20, for instance, so it tells the core to send it all of the traffic for those addresses. Suppose that could be a problem on why the ISP’s connection goes down? Probably more of an internal problem.
Longest matching prefix: say someone in some subnet wants to switch to another ISP but keep their IP, then they can do that and the internet core, when addressing them in the 22.214.171.124/20, will see that this new ISP is advertising a more specific route than that larger one, and so it’ll route traffic to the more specific one.