Hubs are old dumb devices that didn't regenerate signals in most cases. You could literally make a hub by crimping a bunch of network cables together if you did it correctly.
Switches learn MAC addresses and forward packets to the receiver. When the sender doesn't know the MAC address for an IP, the sender broadcasts the packet, which means the packet gets sent to the entire broadcast domain, aka all of the switches connected together. Then the receiver responds back, but this time with its MAC address. Since we knew the sender's MAC address and the receiver responded back with its MAC address, both MAC addresses are now known. All packets from here on out will be sent directly to the port of those two MAC addresses.
Routers route packets between networks and potentially over many different paths. Switches, for the most part, can't handle multiple paths. Remember how I said when a sender does not know the MAC address of the destination IP, so it broadcasts the packet. These broadcasts would quickly destroy a large network because a broadcast packet gets sent to the entire network instead of only the destination. Routers know where to send packets so they don't broadcast packets. routers break up these broadcast domains and can handle custom routes.