The animals confess to being in league with Snowball because they get caught up in the mass hysteria. Mass confessions are actually not uncommon, and they are a kind of mob mentality. They are related historically to the Great Purges of Stalin (see last link).
Snowball is run off the farm, and then used as a scapegoat. In order to keep the scapegoating going, pigs are accused of being in league with Snowball and summarily executed. Other animals then get caught up in the hysteria.
The executions serve to distract the animals from the fact that the hens have to give up their eggs. As Boxer says, “If Comrade Napoleon says it, it must be right.” (ch 7). Not every animal feels that way, but most are too afraid to speak up.
The four pigs waited, trembling, with guilt written on every line of their countenances. Napoleon now called upon them to confess their crimes. They were the same four pigs as had protested when Napoleon abolished the Sunday Meetings. (ch 7)
They confess because they are afraid. They know they are going to die. The other animals also confess out of fear, and because they follow the mob. Most of the animals who confess are the simple-minded ones, and some, like the chickens, probably figure they are next anyway.