There is no compelling logical explanation, it's a plot hole
In the books, Thoros of Myr always lit his blade with wildfire,
Gendry lit a candle and set it on the anvil while he took down a pair of tongs. “My master
always scolded him about his flaming swords. It was no way to treat good steel, he’d say,
but this Thoros never used good steel. He’d just dip some cheap sword in wildfire and
set it alight. It was only an alchemist’s trick, my master said, but it scared the horses and
some of the greener knights.”
—A Storm of Swords
and Beric Dondarrion would slice his hand and use his blood (and a prayer to the Lord of Light) to achieve the effect.
But when the Hound made to step toward his foe, Thoros of Myr stopped him. “First we pray.” He turned toward the fire and lifted his arms. “Lord of Light, look down upon us.”
All around the cave, the brotherhood without banners lifted their own voices in
response. “Lord of Light, defend us.”
“Lord of Light, protect us in the darkness.”
“Lord of Light, shine your face upon us.”
“Light your flame among us, R’hllor,” said the red priest. “Show us the truth or falseness
of this man. Strike him down if he is guilty, and give strength to his sword if he is true.
Lord of Light, give us wisdom.”
“For the night is dark,” the others chanted, Harwin and Anguy loud as all the rest, “and full of terrors.”
“This cave is dark too,” said the Hound, “but I’m the terror here. I hope your god’s a
sweet one, Dondarrion. You’re going to meet him shortly.”
Unsmiling, Lord Beric laid the edge of his longsword against the palm of his left hand,
and drew it slowly down. Blood ran dark from the gash he made, and washed over the
And then the sword took fire.
—A Storm of Swords, Chapter 34, Arya VI
The show's interpretation of that scene is quite faithful. In "Kissed by Fire" (Game of Thrones, S03E05), the scene leading up to the fight between Sandor Clegane and Beric Dondarrion is quite similar to the books:
- They pray to the Lord of Light
- Beric slices his hand on the edge of his own sword
- The blood running down the blade is followed by it taking fire
In "Beyond the Wall" (S07E06), we see both Thoros of Myr and Beric Dondarrion light their swords with no prompt (no prayer, no blood magic, no application of wildfire, no ignition) or preparation that is consistent with what we've been told in the books or shown in the series: it just makes no sense. They seem to be able to telepathically activate it whenever they're in peril.
Even if, as others have claimed, they did coat their swords in wildfire, from the show we know that wildfire requires ignition (the candle under the Sept of Baelor in S06, and Bron's fire arrow in S02) and that it lights green - neither of these stipulations are met in the episode. You'd also have to concede that Beric randomly changed methods, and somehow explain how the wildfire turned off on its own, then turned back on (on its own (no ignition)) in a later scene, which takes place the next day.
“Is it wildfire?” Arya asked Gendry.
“No. This is different. This is . . . ”
“ . . . magic?” she finished as the Hound edged back.
—A Storm of Swords, Chapter 34, Arya VI
Because it is inconsistent with what we've been told in the books or shown in the series, it's an actual mystery, in-universe, as to how it works, and therefore the only thing one can do to try to fill the plot hole (how come he doesn't telepathically activate the flame again to keep them warm) is invent reasons with pure speculation. I can come up with a few relating to stamina/mana, using some basis in other fantasy properties, or that Beric was afraid of ruining his sword since the fire is known to ruin good steel (seems like a harsh outlook on his friends' lives, especially considering a dead Thoros wasn't going to use his sword, plus they had dragonglass weapons), but it's too weak and based on flimsy speculation.
The true answer is that this was a flaw in the writing, a logical error, which isn't all too rare in Season 7.