Mostly experience, but you should get plenty of results by just Googling "mario kart rubber banding". Looks like the top result mentions a patent on an algorithm for it, but I'm blocked at work.
It's a common enough term, though, there's even a page for the trope here:
It's a common enough term, though, there's even a page for the trope here:
http://tvtropes.org/pmwiki/pmwiki.php/Main/RubberBandAI