Somebody cursed the snakes that the nagas will die in the sarpa satra of Janamejaya who did it in revenge for the killing of his father Parikshit by Takshaka. Who cursed those nagas that they would die in snake sacrifice of Janamejaya?
Vinita (Garuda's mother) said that Uchchaihsrava horse' color is white but Kadru (Sarpas' mother) said that it' tail is black. They decided to examine it next day on the condition that loosing party will become slave.
Kadru ordered her children Sarpas/Nagas to resemble the horse' tail as black but they refused to do so and angry Kadru cursed her own children:
And Kadru, bent upon practising a deception, ordered her thousand sons to transform themselves into black hair and speedily cover the horse's tail in order that she might not become a slave. But her sons, the snakes, refusing to do her bidding, she cursed them, saying, 'During the snake-sacrifice of the wise king Janamejaya of the Pandava race, Agni shall consume you all.' ~ Mahabharata: Adi: Astika Parva
Though, Sarpas did the same what their mother said in fear that their mother might burn them that time itself and in hope that their mother might reduce their curse. And, Vinita became Kadru's slave. Later, Garuda had to fight Devas to bring Amrita to Sarpas in order to free her mother from them
Later on, Sarpas' curse was modified a bit that only evil Sarpas will die in snake-sacrifice as it would be stopped by Astika.