The players could have expected this: they've noticed that the dragon has lair and legendary actions. It's clearly dangerous, and it's smart. The dragon presumably needed line of sight to the caster, an unused reaction, and had to be within 60 feet.
BUT the DM hadn't used the spell before. So the players don't realize Counterspell is a thing baddies do. I dunno.
In my current campaign, my caster is really engaged. He watches for enemy casters to use their reactions. He tracks line of sight and distance. But he's been Counterspelled often enough to know it's necessary.
(This is my table, I don't expect others to enjoy this style of play, but as a DM, my final battles will not use mechanics the players aren't familiar with)