Flashbacks work and are often essential for the reader to understand what’s going on and the actions of the character in question.
I learned what I consider to be a better way when writing short stories. Because short stories are short. Every word is important. Can’t waste words on long, involved flashbacks.
But a writer can do what I call mini-flashbacks. A sentence or two inserted in the middle of an action to give a reason for that character’s actions.
Such as a quick comment by a super-macho hero who’s burping a baby found in the middle of a battlefield while he sings a lullaby as bullets whiz all around that he was the oldest of six kids and knows all about babies and that they need security and burping. Does the job, doesn’t use up too many words, lets the writer get on with the story while keeping the character in character.