If you startle a young hatchling, or a large female who is laying on her eggs, those are the main reasons. I have also been tagged after popping a ball python who did not like being popped.
Usually they only bite as a natural instinct for defense, but there are rare circumstances were a ball python is just really high strung and will strike at anything.