In real life people do occasionally act out of character or do things we wouldn’t normally expect them to do. In fiction, there should be a good reason for a character to do something outside of the ordinary.
Craig Hart, The Writer's Tune-up Manual: 35 Exercises That Will Scrape the Rust Off Your Writing
character, character-development, writing