I mean, in the end, they're still just video game enemies with a pretty limited range of intelligence so don't expect masterful strategy and the like, but you'll see that the devs put effort into the AI scripting. However, the moment you go Online, all of that flies right out the window.
Police will just come at you with nary a care for their own bodily well-being and they sure as shit won't be dragging downed comrades out of harm's way. They'll make use of the cover system, but not much else. The reason for this is also why you won't be seeing any animals in Online.
Thanks to the server structure of GTA Online and the mere fact that this is a multiplayer game we're talking about, the CPU draw is significantly increased compared to playing single player. To keep system requirements consistent between the story mode and Online, Rockstar had to cut corners with CPU intensive features in Online, which meant axing the AI first and foremost.
So why wipe out the animals? They too possess fairly advanced AIs for the time and were pretty taxing on the system. Since they didn't much impact the gameplay of Online, they were cut. Since the game more or less wants you to do PvP combat unless in specific missions, enemy NPC AI was downgraded.
When it comes to heists, however, the NPC opponents you'll face will tend to have a greater measure of tenacity than those you mow down in Freeroam. Naturally the reason for this is that the heists are intended to be challenging, pseudo-end-game missions. In these cases, optimization was done in other areas, which ties back to instancing.
When you're playing a heist, you don't occupy the same, regular game world as you do in Freeroam, otherwise all those people in the lobby not playing a heist would come along and rain on your parade. Since you're kind of restricted in where you can go and what you can do while in a heist, the developers could afford to cut pretty much everything that you won't encounter normally, freeing up resources for running better AI in a multiplayer scenario.
If you look at other games, you'll generally see underlying differences between single player and multiplayer that don't immediately pop or aren't apparent. One of the most obvious examples is map size. Way back in the day, many of the great FPS classics possessed large, sprawling levels in their campaigns with all kinds of secret locations sprinkled about, while the multiplayer maps were comparatively tiny arena locations.
Sure, the reason for this was first and foremost a design decision. With a smaller map, players are more likely to find one another, therefore there would be less downtime. A mirrored or symmetrical map was also easier to memorize, making matches more frantic and fast-paced. However, the reason why the advent of large multiplayer maps, save for some notable outliers, is a relatively recent one is because (the average) older systems could either manage a large map or multiplayer, but not both.
Whenever the next time you bump into a particularly dumb pack of hostile police, you'll now know why they're so incompetent compared to their highly-trained terminator cybercommando singleplayer counterparts. Don't ask why the latter can pinpoint snipe you with a pistol from half the map away, because that is beyond us.