Mindfulness. Sometimes people don't realize they bite their nails until it's been pointed out to them or they look at their nails closely. Look into mindfulness based practices (yoga, meditation, etc) which help us train our minds to recognize when we're feeling certain ways in the moment. This helps to choose an effective response (example with anxiety might be taking a walk) vs biting which is "autopilot".
Bite deterrents. You can also try over the counter bite deterrents. You put them on your nails like fingernail polish. They have a horrid taste, that is you bite your nails with it on, you will not enjoy.
Onychophagia. This is not uncommon and is relatively easy to treat. Usually a manifestation of generalized worry (generalized anxiety disorder), it responds to buspirone, anticonvulsants, and antidepressants. Cognitive behavior therapy would also be important.