As discussed in this article, which references an article from Discover Magazine and one from Scientific American on the same topic, a reasonably plausible way for an animal to breathe fire would be by mixing some combination of body chemicals that produce a flammable chemical, ignited with a spark created in their mouth. The article quotes some scientists imagining how it might work:
According to paleontologist Henry Gee, dragons might biologically synthesize diethyl ether. Here’s his quote from the Discover Magazine piece:
“Yeasts and other organisms produce ethanol as a waste product, and there are bacteria that excrete sulfuric acid (they’re responsible for corroding concrete). I could imagine a microbial community in which diethyl ether is made as a waste product and exploited by dragons to breathe fire.”
As the dragon spews this chemical cocktail, all it has to do is generate a spark to light the flame. As Kyle Hill suggests in his Scientific American piece, this might be achieved by mineral coatings on the teeth or ingested rocks and stones in the beast’s gizzard.
The article notes a somewhat similar case, the Bombadier beetle which has "evolved to squirt an explosive stream of heated venom from their abdomen". They do this by combining hydrogen peroxide from one part of their body with hydroquinones from another part, which when mixed in a special "reaction chamber" creates a strongly exothermic chemical reaction which "generates enough heat to bring the entire mixture to a boiling point". Looking at the Bombardier article on wikipedia, there's a discussion of how it evolved:
The full evolutionary history of the beetle's unique defense mechanism is unknown, but biologists have shown that the system could have theoretically evolved from defenses found in other beetles in incremental steps by natural selection.7 Specifically, quinone chemicals are a precursor to sclerotin, a brownish substance produced by beetles and other insects to harden their exoskeleton. Some beetles additionally store excess foul-smelling quinones, including hydroquinone, in small sacs below their skin as a natural deterrent against predators—all carabid beetles have this sort of arrangement. Some beetles additionally mix hydrogen peroxide, a common by-product of the metabolism of cells, in with the hydroquinone; some of the catalases that exist in most cells make the process more efficient. The chemical reaction produces heat and pressure, and some beetles exploit the latter to push out the chemicals onto the skin; this is the case in the beetle Metrius contractus, which produces a foamy discharge when attacked. In the bombardier beetle, the muscles that prevent leakage from the reservoir additionally developed a valve permitting more controlled discharge of the poison and an elongated abdomen to permit better control over the direction of discharge.7
So you could postulate a basically similar evolutionary sequence for dragons, imagining they originally evolved from smaller ancestors which faced dangers from predators, and these ancestors originally started upping the levels of some of these chemicals (ethanol and sulfuric acid, in Gee's scenario) in their body as a natural defense. Perhaps the greatest concentrations could exist in their stomach since Henry Gee suggests in the Discover article that they could be generated by bacteria, and the stomachs contain lots of those. If they were originally herbivores who had evolved a multichambered stomach like cows and other ruminants, one chemical might be more concentrated in one chamber while another chemical might be concentrated in a different chamber (alternately they might have evolved to cultivate microorganisms which produce toxic chemicals in their salivary glands, since this is thought to be the evolutionary origin of venom glands in snakes).
If they had already evolved higher concentrations just so predators would be deterred from eating them, then this might later evolve into a strategy where they vomit up the chemicals of their stomachs when threatened, as a further deterrant. If there was continually selection on this, eventually they might evolve to produce very explosive reactions like in the bombardier beetle. Then, as the Scientific American piece suggests, they could evolve to strike sparks and ignite the chemicals in their mouth by striking together mineral coatings on their teeth, or spitting out gizzard stones to knock against each other and create a spark (gizzard stones are ingested by chickens to help with digestion, and sauropod dinosaurs are thought to have done the same thing).