It’s no coincidence that I just wrote this analysis of rule nineteen of “Pixar’s 22 rules of storytelling” (that aren’t really Pixar’s), I made clear choices that led up to it.
#19: Coincidences to get characters into trouble are great; coincidences to get them out of it are cheating.
There is a gem of excellent advice in there: in drama everything works best if protagonist motivation, choice and action drives her into and out of trouble. Period. Because really, all coincidences are suboptimal. They also appear, to a certain degree, in every story.
When they’re used to get characters into trouble they’re simply more forgivable because the audience gets wrapped-up in the new conflict and consequences. When they are used to get a character out of trouble the result is a deflation of tension and the audience having time to pause and reflect upon how cheated they feel that a tension moment was resolved by fate rather than character choice.
Coincidences to get characters into trouble will be forgiven so long as the audience is emotionally invested in the character, since that's what will get them on board with the new conflict and less concerned with how it arose. But you can't do this too clumsily, too often, or worst of all in a way that undermines the audience's interest in the character.
Like any illusionist if you show your hand too clearly, the audience will see the trick where otherwise they might just relax and enjoy the show. Glaringly clumsy coincidences are the stuff of parody, like a hero saying "I wish the cops would get here" and a second later a ring of cops is pointing their guns at the hero rather than the villain. If you do that then sure, you've just put your hero into peril and increased the stakes, but you did it in such an obvious way the audience will see the trick rather than enjoy the magic.
Likewise, if every turn of the tension ratchet is done by accident, the audience will soon tire of it. People empathize with someone who gets in trouble because, try as they may to do the right thing, their actions keep blowing up in their faces. They are generally less enthusiastic about someone who is passively dragged into conflict by other characters' actions and accidents of time and place -- the very, very rare exception being clever uses of that trope to comedic or paranoiac effect (and even then, the audience still wants at least some of those "coincidences" to be the result of the bungling protagonist trying to find a way out of the "consequence machine" they've gotten trapped in).
Even if you're using your coincidences sparingly, a poor choice regarding the specifics of the coincidence can undermine what the audience most likes about the character and cause them to disengage. This is especially true if it gets out in front of a character personality trait rather than merely a skill.
For example, if you have a character who you've been setting up as a braggart, and then put them in a situation where their bragging should get them into more trouble, but you shove them into the fray some other way, you've just blown it. Let's say you have a tough talking petty crook called before a mafia boss. The audience wants his bragging about his toughness to get him into some kind of trouble here, such as the boss taking his brag at face value and sending him on a hit. But if instead you have the boss give a hitman a job and say "take one of my boys" and he turns around just as your petty crook walks in and says "you, come on" -- you just gave the moment a hapless character deserves to a braggart. You've undermined an interesting trait that engaged your audience with the character, and by not paying off what you set-up you've probably just lost them for good. Even though you only did it once.
Coincidences to get them out of trouble are cheating especially if the coincidence precludes character driven action. If a character is randomly ambushed by an armed opponent, scrambles to take cover, is chased down, cornered, and then -- before your hero can even draw her weapon -- the assailant is hit by a bus, that's not satisfying. The hero didn't get to take any action, not even something that led them into the coincidental situation.
But if a character takes an action that leads to a coincidental situation, you're getting back into forgivable territory. This starts to feel more like good luck than total coincidence. In fact, many set-ups and pay-offs are basically chains of coincidence: earlier in the film you establish something seemingly unrelated to the rest of the plot and them, and later it happens to be exactly what the protagonist needs.
For example, let's say in a cop thriller you establish that there's a beekeeping convention in the downtown convention center this coming weekend. Later, coincidentally, the hero finds out that a villain is allergic to bees. Later still, as the villain is closing in on the hero and seems about ready to win, the hero remembers the convention and in a last ditch effort to escape certain defeat diverts the action into the convention center. She kicks over the bee boxes, and lets the bees do her work for her.
It's coincidence that there were bees and a bee-allergic in the same cop story at the same time to begin with, never mind that the action happened to take place on bee convention weekend. But the audience will (if it's done with enough finesse) potentially consider it clever rather than coincidental.
Set-ups and payoffs are one of a dramatist's greatest tools. It's all about how much care and finesse you us in constructing them. You really can only ever get away with them when a notable protagonist choice has led her straight into the coincidence, and while it's often better to have choice and action lead to direct consequence instead, sometimes a clever, well-constructed chain of motivated coincidence works best.
So like with coincidences to get a character into trouble, the ones to get them out are most egregious if they're too obvious, too frequent, or poorly timed and staged such that they undermine character moments. And the most infamous example of this is when it comes during the conclusion of the story, a problem so egregious yet so common it has its own term of art: Deus Ex Machina.
The term translates to "God In The Machine" and basically means "some invisible external actor (ultimately, the writer) solves all the protagonist's problems for them". Many otherwise interesting stories have been completely ruined by Deus Ex Machina conclusions, in which the main character is removed from the central action of the climax by outside actors solving everyhing for them.
A particularly infamous and frustrating example of this is the computer entity actually named Deus Ex Machina in "The Matrix Revolutions". A literal God in the literal machine swoops in and solves all of Neo's problems for him. And when the coincidence actually resolves the entire story a nod towards character action motivating it just isn't good enough. Drama is dramatic because protagonists save the day when God can't get the job done (or die trying, in a tragedy), not the other way around.
In essence, what this rule is trying to say is that your protagonists' motivations, choices and actions should always be what gets them into and out of trouble, and any coincidences involved need to seem like exactly the sort of thing that would happen "accidentally" to a character that makes those kinds of decisions.