The ants are giant packrats!
The gold digging ants are not typical ants,
There are also ants that, according to some bestiaries, live in
Ethiopia or India, are the size of dogs, and dig up gold from sand,
guard it, and pursue anything that tries to steal it, especially
greedy humans. Artists depicted these ants not as larger versions of
the familiar-looking insects, but more like actual dogs.
The mountain ant
In ancient Persian the word for marmot was "mountain ant". And the
mountain ants do indeed dig up gold on occasion.
Now a team of explorers says it has solved the puzzle. The explorers
believe they have pinpointed the land of the legendary gold-digging
ants and the people who profited in one of the most inaccessible
regions of the Himalayas along the upper Indus River.
They say the outsize furry ''ants,'' first described by Herodotus in
the fifth century B.C., are in fact big marmots. These creatures --
Herodotus calls them ''bigger than a fox, though not so big as a dog''
-- are still throwing up gold-bearing soil from deep underground as they dig their burrows. Most important, the explorers say they have
found indigenous people on the same high plateau who say that for
generations they have collected gold dust from the marmots' work.
Here is a colony of these big marmots.
But these marmots don't care about the gold. They just bring it up. Why would a rodent care about shiny gold nuggets enough to hoard them and even fight for them? There is one rodent that does. Packrats!
That morning as the horse and mule were loaded Tucker noticed a hole
in his saddlebag with gold dust spilling from it and cussing that rat
for chewing into the bag he began unpacking to save his precious gold,
but it was gone…Only the fine gold that hadn’t spilled from the pouch
into the saddlebag after being chewed apart by the packrat remained.
All of the nuggets were gone as well as his pocket watch, and other
objects small enough for the critter to haul off.
So: your "ants" are colony dwelling, burrowing rodents with a packrat-like habit of hoarding neat things, especially shiny things. In the above linked article, the prospector who lost his gold to the rat spent several days digging into burrows trying to find the one where his gold was, without luck. The article concludes by speculating that in an area naturally rich in gold nuggets, resident packrats might accumulate nuggets over time, giving rise to nugget troves in ancient rodent dens.
I am not sure a marmot would charge a guy with a sword like the ones above are doing but I would not want to test them. They are pretty big one at a time, marmots.
@chasly from UK pointed out that this answer does not cover the evolutionary angle; true. And a downvote for this lack - horrors! I was unable to find any thing written about why packrats might favor shiny things for their nests. I have taken this speculation on myself.
Packrats like to incorporate shiny things into their nests - this is well known.
Packrats like to use old nests if they can find them. It makes sense - if a nest has long been inhabited that means it is a good place for packrats. Plus older nests are more substantial, in part because of...
Rats and especially packrats urinate onto their nests. Over time the accumulated urine can crystallize, cementing the nest material together into shiny masses called amberrat. These cemented nests are durable and of use to paleontologists, as the preserved materials record eras past.
Thus we have selective advantage for rats that like old nests, and old rat nests tend to be shiny. This could mean a selective advantage for rats who like shiny nests. Such rats will make their nests shiny if given materials to do so because they like shiny nests. Gold nuggets are definitely shiny. Thus - selective advantage for "ants" that seek out gold and incorporate it into their nest.