Fuel gauges used to so much simpler. My 1965 Super Minx had a simple fuel sender unit inside the tank which was connected to the fuel gauge. As the float inside dropped (as fuel levels dropped) the needle moved accordingly.
Only trouble was the needle used to bounce up and down as you went over bumps!
To a certain extent, they're still like that today! They still tend to have a float and a variable resistor on the end of it. However, as you say, the gauge needle would bounce all over the place during "spirited" driving, and that all became worse in the 1980s when cars started to be fitted with low level warning lights. Depending on the car and the road, you could get a period of about 50 miles where the light would flash on and off randomly before becoming permanently on, as the level changed round bends and up and down slopes or accelerations.
These days, many cars just take an initial reading from the float as the ignition is turned on (before the car starts to move) and that voltage is translated to a digital code by the computer in charge of such things. The computer then tells the gauge what to read, but as the car is driven, it ignores the float in the tank altogether and instead, just counts the injector pulses and calculates how much fuel has been used. This has the advantages that:
(a) the car can be thrown around as much as the driver likes and the gauge won't move, plus the low fuel warning light will either be on or off, but not randomly blinking and
(b) the tank can be whatever shape it likes and the gauge can still be (more or less) "linearised" via the software - so in theory at least, the gauge should move the same amount for the same mileage regardless of whether the tank is full, 3/4 full, 1/4 full or whatever. In practice, few manufacturers seem to bother optimising it fully though - as long as it reads empty when it's empty!