If somebody orders, say, ribs, and mentions they are allergic to spices that are found in some barbecue sauces or spice rubs, the waiter isn't going to know (and the cook might not know) if those spices are in the dish, and especially won't know if they're present in a large enough amount to cause a reaction.
The FDA does require manufacturers to keep track of the most common allergens ( https://www.fda.gov/food/nutrition-food-labeling-and-critica... ), but if somebody has an uncommon allergy, they're on their own. Restaurants are regulated by state health departments instead of the USDA. California, I believe, has some allergen labeling requirements for its restaurants. Most large restaurants worry enough about liability that they disclose the information (for common allergens) voluntarily.