Gas is not undertaxed, weight is undertaxed. Road wear grows exponentially with weight. The biggest factor in road wear is how many loaded semi-trucks drive down it.
Until EVs came out, gas was a pretty convenient way to tax weight. The more size/weight of your vehicle, the more gas/diesel it used.
In countries like the US where diesel is rarely used for passenger vehicles, you can even separate fuel type between commerical and personal use for tax purposes.
Road wear is definitely the one that the gas tax is intended to pay for, though the true answer is that most negative externalities for cars are not really intentionally paid for by society.
E.g., with premature death due to car crashes, nobody's really paying for the fact that a person stops working and paying taxes because they no longer exist. The auto manufacturer doesn't pay for that, the auto insurer doesn't pay for that. You've got to end up in civil court with injury attorneys to even hope to pay for that, but even then the source and destination of the money might not be "correct."
In countries like the US where diesel is rarely used for passenger vehicles, you can even separate fuel type between commerical and personal use for tax purposes.