Sometimes, you have two characters talking to one another and then as a character is about to describe what happened to the past, a flashback can be seen, and this is done in movies often. Now, I am wondering how to exactly do this in a novel. One issue is that the flashback can be several pages long, and so cutting back to the dialogue could really mess up the flow of the narrative, and I am also wondering if you should skip to the next paragraph when doing flashbacks like this, and some other formatting rules that people are expected to follow when introducing a flashback mid-dialogue.
It depends on the amount of detail in the flashback that's relevant to the present day story.
One thing to keep in mind is that flashbacks are often memories. If two characters are talking to each other, you probably don't want one character suddenly drifting off into a two page memory - the reader will be aware the other character is sitting there doing nothing. If the character is recounting the past, then it's possibly best done in dialog anyway.
If you really want to add a detailed flashback, and involve dialog, the only way I see it working effectively is by having Character 1 and Character 2 in dialog, Character 2 says something that unknowingly triggers a memory in Character 1. Character 2 has to leave for whatever reason, and Character 1 is left on their own to reminisce, and then transition into the flashback.
Generally, two characters having a conversation through flashback scenes (I.E. the flash back plays out on the screen, but a disembodied voice of the person listening to the story and the story teller) are something best portrayed in visual media (Such as film, TV, video games, or comics) where the voice of characters not in the scene can be played over the scene for audio effect (in the case of comics, dialog boxes will represent voices not organically in the scene).
Flashbacks in books typically shift the perspective off the present-day characters and onto the past character of the storyteller, typically by a chapter break, and at other times the "story of the book" is framed as the person hearing the story told by the participant having met him after the fact. In the 19th century, especially in the horror genre, it was popular to writen Epistolary Style novels, which are stories told by communication between characters who were party to the events of the story, placing the reader in a position of the character hearing the story. The reader's POV is thus that of someone investigating something using primary stories written by the principle actors (Dracula was a series of letters and journal entries, Frankenstein was the Doctor telling a stranger the story of the events surrounding the monster, Dr. Jekyll and Mr. Hyde was a letter from Jekyll's lawyer detailing the case, and Sherlock Holmes was framed as recollections of his assistant, Dr. Watson, about their adventures.
Some books that rely heavily on Flashbacks include Holes, a story of a kid in a Juvenile Detention camp in the Texas Desert, for a crime he did not commit. As part of the program, the warden has all the inmates go into the dry lakebed and dig a hole to a depth equal to the shovel handle's length and a width measured using the same measuring tool. Because such work is tedious and long, the POV character Stanley reminisces about the circumstances that got him wrongfully accused of the crime and how it was yet another turn of the "family curse", then the time his grandfather told him the story of the ancestor who came to America after invoking the wrath of a gypsy woman who put the curse upon him and his children (at one point, this flashback occurs within the former flashback). A final flashback occurs and seems triggered by the camp counselors (though it doesn't appear anyone tells this to Stanley) about the origins of the camp, which used to be a prosperous town in the post civil war era, until it befell a curse in the after the murder of a black man who was believed to have been in a relationship with the white school teacher. What is unusual here is that Stanley is at no point fully aware of the significance of the three stories to the adventure he is presently embarked on that will result in the breaking of two curses.
For a simpler read, (with visual cues to boot), Dr. Suess' "The Lorax" is an unusual case that has a First, Second, and Third Person voice to shift between the present day introduction, the flashback, and the present conclusion of the story. In this story, the POV character is an audience surrogate who is seeking out an audience with the mysterious "Oncler" who lives on the edge of a rundown town (in the film, the boy is named "Theodore" after the book's writer, but in the book, this portion is told in the second person, making it clear that the reader is supposed to be the boy, following instructions from an Urban Legend or campfire story he had heard prior to the book's start. After the boy properly incentivizes the Onceler to tell his story, the Onceler begins with a "Once upon a time invocation" at which point the stories tone shifts from an ominous foreboding to a joyous, vibrant tone that captures the Onceler's fond memories of the discovery of the town's sight and the beauty of the environment when he arrived. At this point, the narrative voice shifts to the Onceler's first person perspective, and the tone slowly shifts to arrogance and hubris before a sudden shift when the Onceler realizes too late his folly in overharvesting the resources of the valley. Upon return from the flashback, the narrative voices shifts again, as the Onceler leaves you, the curious boy, with a decision. As such, you are no longer following instructions as you were when the story began, but posed a moral question of what the child's next step will ("Unless someone like you cares a whole aweful lot, nothing is going to get better, it's not.") becoming a child and eco friendly version of "The Lady and the Tiger." The book doesn't offer a happy ending, but the promise that one can be achieved if the reader... the boy... chooses to work for it.