Most times they bite when they feel threatened and have nowhere to run. But they also may bite if you feed them something and the scent is still on your fingers, like green pepper for example. Or they may bite if surprised and they don’t see your hands before you pet them or pick them up. Their vision is not all that good, they lack depth of field so they can’t judge distance, and they can’t see below their noses.
Mine does not bite when I handle her, as long as she sees me reach for her and she is in an open area of her pen. But if she is cornered in an enclosed area like her pigloo, I have to cover my hand with a piece of fleece because she bites.