Loki’s cleverness was his own undoing.
He was trying to figure out how his enemies might catch him, now that he spent most of his days as a salmon, hidden deep in the water near a great waterfall. He wanted to make sure he’d considered every possibility, so he’d have a plan for every eventuality.
He invented the first fishing net. “Yes, that’s how they might catch me, if they’re clever enough to think of this too.” Then he shook his head and smiled. “I don’t think I have anything to worry about.”
From this vantage point, camped on the hill above the water, he could see his enemies approaching. Quickly he threw the net into the fire, turned into a fish, and leapt into the water.
By the time the gods arrived on the hilltop, the net was mostly burned away, but they could just see its outline in the fire as it burned, and it was enough to give them the idea to make their own. And so they did, and fished for Loki in the water.
(I’ve been reading The Prose Edda by Snorri Sturluson.)