How do these ports work?
When a USB is connected to the corresponding port, it goes through a process known as enumeration. In this process, the host queries all the devices and assigns each device an address. The host then finds out what form of data transfer it wishes to preform. Devices like mice and keyboards go into the interrupt mode as it will be sending only a little bit of data. Devices like USB drives and printers choose bulk mode, meaning that it will obtain a large packet of information at one time. Streaming devices like speakers and projectors use isochronous mode, which allow for data to be streamed from the host to the device in real time without error connections. Once the device has chosen the mode it requires, it can then transfer the data inputted or outputted. Here are two videos explaining how these ports work
What is inside a USB cable?
USB cables contain four wires. A red wire that carries the power supply (-+ 5 volts), a brown wire (ground), and a pair of blue and yellow wires that are twisted together (carry the data). All these wires are shielded.
What's inside a USB drive?
This is a video that explains how the USB drive works.
How many devices can I connect to my computer at once?