There are rules in golf about the maximum length a driver shaft (or any club shaft) can be. This doesn't impact most golfers, but it's important to know the limits.
The length of the driver shaft in modern products isn't anywhere near the maximum length of driver allowed by the USGA under their equipment rules and regulations. The maximum length a driver can be under equipment regulations is 48 inches.
In the modern era, most drivers are 45 inches or 45.5 inches. They're longer than they used to be, even compared to a decade ago. Before modern materials, drivers were typically in the 43- or 44-inch range because they were more difficult to control.
The USGA measures length as taken when the club is lying on a horizontal plane and the sole is set against a 60-degree plane. The length is defined as the distance from the point of the intersection between the two planes created by the plane and the angled plane all the way to the top of the grip. In other words, that's typically where the driver shaft would break through the sole of the driver if it extended beyond the hosel.
This means the maximum length of a driver shaft isn't 48 inches. The shaft is obviously the biggest part in determining if it conforms with the maximum length regulation, but the depth of the driver head also determines that.
Competitors in the World Long Drive tour must also use drivers whose lengths conform to USGA guidelines. That was not always the case, but it is now.
It should also be noted that the maximum length of a driver is also the maximum length of any club in the bag that isn't a putter. Hypothetically, a golfer could carry a bag of single-length clubs that all measure 48 inches, other than the flat stick.
The biggest reason why drivers are longer than they used to be is because driver shafts are more stable and more refined, so they hold up better at all swing speeds. In other words, driver whip is different and fits individual golfers better at every flex. The other big reason for increased length is improved head design. Modern head design makes the driver more forgiving and allows players to keep the ball in play more frequently, allowing them to handle a longer shaft and some of the added variance that comes from it.