New snakes, especially young ones, often bite if you don't leave them alone for their first week in their new home. Especially if they had a rough trip with FedEx, or if you put them in a too-large tank with not enough hidey-holes.
Some really young hatchlings bite because they're really really HUNGRY, and they don't know the difference between a finger and a mouse yet.
Most of my young/new snakes grow out of biting in the first few weeks that I have them, but I've had a few (say, one in five?) that keep on biting for most of their first year. I don't know if they're insecure or just plain surly. My first snake, Mr. Nibbles, seemed to get a kick out of wedging himself into corners, or perching himself in a spot with a nice view of the room, and then GUARDING it. He liked to guard my laptop. From me. (I guess it was warm?) And my pewter female seemed to badly want a piece of me for the first 8 months I had her. At one point I was holding her in such a way that she couldn't get either of my hands, so she threw herself around in a bizarre pretzel twist and BIT MY ELBOW.
None of my adults/subadults bite as a rule, but I have a few that get really grumpy when they're deep in shed. Occasionally they'll decide it's ridiculous that I'm cleaning when they want to be left alone, and they'll let me know it.