A managed switch can do this. Some routers claim to be able to, but fall short. Hubs are 'dumb' devices that just mirror traffic on all ports.
Burn: Switches connect devices on the 'same' network. In your example, the two routers are on the same network (the internet is a network) --PC1/2 are on another and PC3/4 are on another. The routers allow the 3 networks to be connected.
A layer 2 device is called a layer 2 device because it makes forwarding decisions based on a layer 2 address, aka MAC address. How these devices operate depends on whether they are bridges, hubs or switches. A layer 3 device makes forwarding decisions based on a logical layer 3 address, i.e. IP address.
You're right, a hub is simply a multi-port repeater. As such it doesn't require any type of processor or often any additional power aside from what comes through the patch cable that is connected to it. When switches first came around they were called "smart hubs." While a hub simply repeats the same signal to all ports, a switch has some sort of processor and software (though this may simply be a few kilobytes on a flash module) and would only have to do this once, after which it would send information to the specific MAC address of the intended device (i.e. the NIC card of a specific computer) through a virtual circuit.
I haven't had any conversation containing the OSI model in a long time, its nice to get back into networking nerd-dom.