Why did I have a random Frost Troll attack in town?

Solution 1:

This is probably just the AI being AI.

There is a spawn point for frost trolls right next to the town of Dawnstar on the other side of the hill near the road that leads into town. If you stand on top of the hill you should be able to see the trolls easily. There are also different types of creatures that spawn in the area that the troll would try to attack. Chances are while you were waiting for the Khajiit merchants to reset the troll followed the creature AI up towards the town close enough to start locking on to the people in the town.

If you are wondering if there is some kind of scripted event for a troll attack on the town, the answer as it currently stands is No. This is just some of the randomness that comes along with the world of Skyrim.