how is this working without installing any specific drivers?
The Linux kernel offered by most distros as default already contains a large number of drivers. Most Ethernet-to-USB adapters are marked in the USB descriptor as a CDC device, so one of the standard drivers (there are several variants) will do for most devices.
I guess when this device is plugged in, udev sets it up, but how does it know that this USB device is actually used as an interface that connects to Ethernet and hence routes traffic over it?
All kernel modules can contain patterns that describe for which devices they can be used. These patterns are called
alias. If you do for example
modinfo cdc_ether, you'll see quite a number of aliases starting with
usb. The rest of the aliases matches on values in the USB descriptor.
All aliases are collected into a
modules_alias file (in
/lib/modules/<kernel_version>/), and then the kernel uses this file to decide which driver to activate when a new device (USB or other) is found.
The driver itself will take care of telling the kernel that it represents a device that has a representation in other kernel layers, e.g. a network interface. These upper layers then will take care of other steps, sometimes using interactions with user space, to initialize the network interface, set routes etc.