You shouldn't get a bounty if you let them attack you first. This is what I did with all the prisoners I help escape. First, I selected the option to free the prisoners which caused the Thalmor agents and Imperial soldiers to become hostile, then I killed them (after they hit me first of course). End result = no bounty.
Or maybe you were doing it too close to a hold, IDK. All of my escapades were carried out in the middle of nowhere.
This.
I've killed Thalmor patrols in the middle of nowhere, and I had no bounty afterwards.
I've killed Thalmor and Imperial patrols in sight of a Hold capital, but not really near it; no bounty.
I've killed both types of patrols within sprinting distance of a city; 2000 gold bounty...
I free all prisoners too BTW. I don't give any of them equipment, I just let them run off. Since I'm in the Dark Brotherhood, I don't get the DB assassins coming after me. I tend to get the Thalmor agents, or the band of three "Hired Thug"(s) that are there "to teach me a lesson..."
But guess who ends up getting schooled instead? heh heh heh

OT: I do think that the bounty directly relates to how close you are to either a Hold City/Guards. Like I said, when in the middle of nowhere, I tend to slaughter them at will with zero bounty.