When your pans are scratched, the nonstick coating can flake into your food, which can be harmful to your body. However, this usually only applies to manufactured nonstick pans.  If you’re working on a cooking surface that has a natural nonstick like cast irons and carbon steels, it’s okay, and you don’t have to worry about it being unsafe. You’re just probably not going to enjoy cooking on them. Also, if they’re only lightly scratched, there are methods on the internet on how to cure them.