Electrum protocol supports notifications. when you connect to an Electrum node you have an open socket and a bunch of subscriptions to certain addresses which the node will inform you about when there is any new transaction that involves those addresses.
more info can be found on the documentation:
https://electrumx.readthedocs.io/en/latest/what is Electrum protocal ? is it bitcoin feature or configuration option in bitcoin.conf ?