That’s called “tempo quantize”. Audacity doesn’t have that, but most of the big “DAW” applications (such as Cubase, Sonar, Logic Pro…) have it.Personally I’ve not found it to work very well, so better to play in-time. Playing to a “click track” can be a big help.
Yeah… Pros generally prevent the problem by using a click track.
But, in case of professional musicians it isn’t so much for making a “perfect performance” or “perfect timing”. It’s for “comping” where they combine parts of different takes together. For example they might take the 1st verse vocals from the 1st take, the 2nd verse vocals from the 3rd take, and the guitar solo from the 4th take, etc. It also makes it a lot easier to combine live musicians with MIDI.
Or sometimes, the drums are recorded first and used as a click-track to make sure all of the takes match. The drum track may have intentional tempo changes or just some human imperfection. (Of course you can program intentional tempo changes into a click-track too.)
Traditionally, metronomes are for practice and during a performance the tempo is maintained by drummer, conductor, band leader, or solo performer. Lots of recordings were made that way. Most live music is still performed that way except where there is programmed MIDI or recorded backing tracks. If you look at classical sheet music, there is no BPM, there are some Italian words for “fast”, “slow”, “sped-up”, “slow-down”, etc., and no two performances will ever be exactly the same.