I'd guess that this is an area of perpetual ongoing development... I presume Kunos being Kunos, they aim to keep the AI operating strictly within the bounds of physics, without coding in artificial advantages to keep them competitive... which means they have to "teach" the AI (in whatever applicable sense) to actually drive each circuit on the limit of grip, while also maintaining their ability to be aware of and react to other cars cleanly, etc, etc.
Honestly, it's a mind-bogglingly complex AI puzzle... and one that presumably requires massive amounts of hand-tweaking for each and every corner of each and every track (for each and every different car), and presumably requires re-tweaking every time they change the tyre model or such.
I'd say best to just accept that on some tracks, they're going to be slightly off the pace... the alternative is AI that effectively cheats... and nobody wants that :-P