Only small dragons collect coins; large ones don't need to
Dragons hoard gold for the same reason many birds collect shiny objects: to adorn their nests and attract mates. Unlike birds, though, dragons never stop growing, even after reaching maturity.
A young adult dragon is only moderately bigger than a human. When they are first making their nests, they usually target individual, defenseless peddlers, killing them and taking their purses, which they carry in their claws or mouths. As they grow larger, they will begin attacking caravans which might be carrying large chests.
Of course, dragons are highly territorial. Large dragons will often kill or drive out smaller dragons living nearby, then stealing gold from their hordes. Some devious dragons will intentionally allow smaller dragons to live in their territory for a while in order to collect more gold before taking it from them.
Sometimes, dragons will live in family groups, with the young collecting gold for the family. Dragons with larger hoards will typically have more mates, and more children, allowing the size of their hoard to grow exponentially. Sometimes, a child may "inherit" a portion of the hoard when they leave the nest to build their own, although they will usually not take as much away as they put into it in the first place. Other times, especially in wealthy dragon families, dragons may spend a good part of their lives living in their family's lair; the huge size difference between older and younger dragons means that younger dragons are only able to mate with younger partners, preventing competition between generations.
Larger dragons, naturally, will attract adventurous humans to their cave simply by virtue of living there. Whatever was in these adventurer's pockets at the time will naturally be added to the hoard.
Most dragons have only a single hoard. However, extremely large dragons may migrate between lairs. When they are away, it is possible that a smaller dragon will attempt to take over their hoard, and will likewise end up adding to it. When the owner returns, whatever the smaller dragon collected will be added to the hoard. Some larger dragons will actually encourage this, seeing the additions as "payment" for use of their nest. Only the largest dragons will do this, as it otherwise carries the risk of a similarly-sized or larger dragon squatter that cannot be driven away so easily.
Dragons who are feared by humans may increase their horde even further by allowing humans to live in their territory in exchange for occasional tributes of gold.
By the time a dragon reaches legendary sizes, it is no longer collecting coins, instead targeting larger, more impressive fare like golden statues or the crowns of kings. However, an ancient dragon is still likely to have truly colossal piles of coins thanks to the accumulation of collection by children, squatters, adventurers, and tribute.