It’s not. The swords found by the adventurers in The Hobbit are from Gondolin, a city that was destroyed long before Gondor was founded.
As to why they were found, I think that Tolkien decided his characters needed to acquire magical weapons, and wrote the episode with the trolls in order to accomplish that.
As to why the swords were there, you can find out more by reading the Silmarillion. In brief, when the Elven city of Gondolin was sacked by Morgoth during the First Age, its populace was slaughtered and everything of value was carried off by the orcs, trolls, and other evil creatures in the victorious army. I would guess that the swords were found and looted by trolls instead of orcs. The orcs hated these weapons, and if they ever possessed them would surely have either destroyed them or kept them for themselves to make sure they could never again be used against them. I can only speculate, but I would guess that the trolls kept these valuable treasures hidden in order to prevent them from being confiscated by more powerful servants of Morgoth. Apparently, they were kept hidden and passed from troll to troll for several thousand years, until they finally ended up in the possession of a rag-tag bunch of hill trolls in the wilds of Eriador.