The process of making a car legal to race in a particular motorsport class is known as homologation ("to approve or confirm officially"). Basically, some racing classes require manufacturers to sell a certain number or road cars (or race cars which can be purchased by the public), for them to be eligible to race.
Some famous examples from the era of FIA Group A rules include Mitsubishi's Evolution Lancers, Nissan's R32 Skyine GT-R, and the BMW E30 M3.
These models are comprehensively upgraded above the bread-and-butter E30, R32 and Lancer variants to be suitable to then be built into a lightning-fast racing car. This meant the road-going variants Joe and Joelyn Average would buy from their local Car Dealer needed to be fitted with bespoke engines, lighter chassis, upgraded suspension and brakes, and much more as they would provide a better basis for the race teams to then create their track-only models
From the 1960s-1990s, during the heyday of production car-based racing, homologation rules were tightly controlled to stop manufacturers cheating hard. This gave us some of the greatest performance cars of all time, including wild winged monsters like Dodge's 1969 Charger Daytona and the 1970 Plymouth Superbird, all the way to rally beasts like Lancia's Delta Integrale and the R32 GT-R Skyline.
Ultimately homologation specials were legislated out of existance. Safety concerns forced motorsport governing bodies to move to purely fabricated race cars that have little or no ties to road-going machinery.
Surely the wildest homologation car ever was the 1994 Dauer 962 LM, which is basically a 400km/h Porsche 962 Le Mans race car that dominated the wild Group C era of sports car racing. But with number plates. It was made available to exploit a loophole in the rules for the 1994 Le Mans 24-hour race, and only a handful have ever been sold, which is probably a good thing as they are regarded as one of the fastest road-going cars of all time (but still not as maaad as a Super-Turbo!)