When bandits wander too close to an Imperial-aligned town, they get attacked by the guards. When the Thalmor do it, they don't.
The business in Markarth is a confusion between factions. The Jarl of Markarth is Imperial-aligned, yes, but he's not part of the Legion and neither are his guards. The Thalmor know that the individual jarls are significantly more unpredictable than the Legion, and therefore harder to control. Igmund, to his credit, has enough basic sense of justice that he declines to sentence a man without any evidence whatsoever, and the Thalmor may hate that, but they accept they have to work with it.
Actually, this one I do know. The trigger is, "reach level 8". (I think it's 8. In that ballpark, anyway.) There is no other requirement.