Most modern aircraft are capable of providing a lot more data over their radio transponder, including a system unique identifier, but it turns out that "squawking" a four digit code is a useful amount of discretion to give humans. If you could do it over maybe a decimal code would have been better, but too late now.
do modern mode 3 transponders also include tail number or some other unique identifier in a sideband?
https://en.wikipedia.org/wiki/Automatic_Dependent_Surveillan...
(I don't know how much squawk codes are, or were, used to specifically identify aircraft in the past, but I believe that currently it's not unusual that many aircraft in the same region would be squawking the same number, which would not confuse ATC because of all the other transponder data that's available.)
In Europe some areas (but not all) have switched to using the Mode-s/ADS-B identification (which is a 24 bits unique code not configurable by the pilot but fixed to the aircraft) in their systems and setting the traditional transponder code to 1000 for all of those aircraft.
In the long term expect everyone to adopt that approach, but things in aviation move very slowly so it will be many many years before we're there.