I'm not convinced I would call the AI's use of features such as either garrisoning or raiding as failed, based on my experience. Annoying is harder to qualify as it's entirely subjective: losing a province to an AI force that for once didn't just raid was (at the time) unexpected and annoying for me!

The point regarding the AI garrisoning troops that would perhaps be better used in their battle line is a good one. Unless defending the streets of a town, the AI shouldn't garrison a building that won't form par tof it's battle line (eg as an anchor or hard-point).

As to the destruction of garrisoned buildings and the evacuation of the troops,
1. I think you should be able to destroy the buildings with all troops inside if you can bring enough fire power to bear in a short space of time
2. the point at which a garrison evacuates a building under fire is surely similar to the decision to form square or line, based on the proximity of cavalry.

Ultimately, both of these AI decision are ones that the player seeks to exploit in order to destroy the unit(s) in question. At what point does one draw the line between the AI making "good" and rational decisions and exploiting cheats like reacting to the player switching to cannister shot?