Center for Disease Control and Prevention (https://www.cdc.gov/healthywater/hygiene/hand/nail_hygiene.html) suggests keeping a good hygiene of your fingernails and toenails as well as sterilizing your nail equipment to prevent nail infections. Here are what you should do to prevent nail infections:
Keep your nail short
Longer nails can keep more dirt and bacteria more than short nails.
Wash underneath the nails when you wash hands.
You can lightly scratch your palm with your nails to wash out the underside of the nails.
Sterilize nail tools (i.e. a nail cutter) before use.
This is especially important when the tools are shared by other people.
Do not bite or chew your nails
Instead, use a clean nail clip to trim your nail.