What you witnessed were death throes. When a snake starts twisting and turning and biting randomly like that, the end is nigh. At that point, there was nothing you could do to change the situation. Most illnesses are going to show some kind of symptoms before you get to the end stages. I think Bogertophis's is on the right track with likely overheating. I'm not sure where you took the snake or how but overexposure to the sun is not something people often think about and a lesson most learn the hard way. I learned firsthand about the greenhouse effect when I was a kid and cooked some Sceloporus I had field collected and left out on the deck in a coffee can while I went inside to eat lunch. It was a cool day and I thought nothing of leaving the can in direct sunlight. Came back maybe 10 minutes later to dead lizards and boy did I feel terrible. To this day I'm extremely careful, borderline paranoid, about unchecked sun exposure. Even in a cool car, something in a container that's set in direct sunlight can heat up to lethal levels faster than you'd believe. Not necessarily what happened to your snake but something to be aware of nonetheless.