Sure you can eat them, but in the interest of health and weight loss (as well as maintenance), it's always best to rely on real, whole foods: snacks like tuna, avocado, nuts, eggs, lightly roasted chickpeas, plain Greek yoghurt (or pudding made from plain Greek yoghurt mixed with protein powder), etc. Most protein bars are essentially candy bars: they're ultra processed, high in calories, low in vitamins and minerals, often high in sugars and/or fats and salt, and most are full of sugar alcohols that can cause stalls and even weight gain for people trying to lose weight. If you read around this forum and on other weight loss and WLS forums, you'll find that they're also a "slippery slope" for some in that they can lead to pretty intense cravings for bad carbs. The only thing that really separates them from candy bars is protein content.
If you're craving a treat but would like to combine it with a quick hit of protein, it's very easy to make your own protein bars or balls. There are loads of recipes online; just search around for the healthier ones that don’t contain added fats and oils, added sugars including dates or dried fruits, etc. They take only a few minutes to make, and the nutritional profile is far healthier than any of the commercially made ones.