The more you flesh out your characters, the less of a personality margin you leave for the decisions they make. For this reason, plot-driven stories tend to spend less time on characters and more on other parts of the story; the world, the plot twist later on, etc. Alternatively, you have character-driven stories, sometimes taken to the extreme, where the world is created, the plot elements placed, and the characters started off, and the story naturally evolves.
Often, you want a character that grows naturally, hints at all the things that would make them react a certain way. People can relate to a character that they understand. When someone acts irrationally, only people used to irrationality can understand them. This can be a subtle hint, maybe simply their gruff personality is enough to suggest a bad past with people.
A cheap method of making characters act a certain way is unsaid, pre-existing events. While you can sometimes work around a drastic change of character behaviour (e.g. with a traumatic memory surfacing up and usually calm character loses it), it will seem to be added in rather than a pre-existing condition. And that's when immersion breaks: readers start to not understand the character.
Alternatively, a reasonably safe choice is unpredictable events:
Alice leaves Bob amicably then many months later, in their next scene, they're betraying Bob - if Alice never explains why, it will feel forced to the reader. In contrast, if Alice met Charlie during those months, who on their deathbed fed Alice a pack of lies about Bob... then why Charlie lied may need explaining, but why they're a liar doesn't need explaining. So Charlie remains little more than something to move the plot, yet readers don't mind his unpredictable effect on the plot because without a full personality, he's unpredictable.
But this can't happen for any character you want the reader to relate to, because the reader will no longer understand them without a personality.
For things that aren't changes, but new elements... then you have three things that can divert a plot instantly without explanation: animals, crowds, and voice recognition software.
"Ok Google, call Alice."