My opinion is, that AI is aimed at the most dangerous, from their point of view, rival. To save your units, you yourself must become such a target for them. But that doesn't always work, and there are times when they just ignore you.
How aggro mechanic seems to work is based on 'who' seems the most threatening to them yes. If someone is attacking their shield, they'll designate that person as their target, but outright ignore the other enemy designating him as a target. So when he swings his weapon the other enemy will see a opening and attack him.
In terms of formations, I think shield walls are too tightly packed a bit, where they can't even swing their swords at enemies up front at a angle because it hits the next shield. Only spear users with shields do better for shield walls but their damage potential is really poor up close.
Imperial culture uses one handed swords of somewhat long length, which kinda works against them in a shield wall formation.
If they were using very short weapons at a length of say 50, in a shield wall, they would be far more effective though weaker.
Maybe make all formations adjust the AI's preference of attack, so when allies are next to them, they prefer to thrust or overhead slash? I find it dumb they attempt to do horizontal cutting when allies are literally standing should to shoulder.