It's most likely the second one because it states in the song "as they tried to teach me how to dance" meaning the purpose for their contact was for teaching and any hugs were accidental
But they're not real fireflies. They're supposed to be a metaphor for his racing thoughts as he tries to fall asleep. And the fact that he gets a thousand hugs from ten thousand lightning bugs seems to mean that he can only grasp a few thoughts out of the thousands.
Because why else would fireflies be giving you hugs?
By 10.000 lighting bugs"