To answer the actual question, in general if the 'gratuity" is actually stated on the menu, then yes, you can be obligated to pay it. You might be able to find a lawyer who can wriggle out of it, but not at a cost less than the gratuity. There have been (extremely rare) incidents where the police have been called over refusals to pay a gratuity.
If the tip wasn't explicitly mentioned on the menu (or if you don't remember it being mentioned) then you should absolutely query it. Some places have been known to add a strictly optional tip making it look as if it was part of the bill. At least ask if paying the tip is compulsory.
18% is considered a normal tip. However if you think the service was not up to standard, you should absolutely talk to the restaurant about getting it reduced. They are going to be much more amenable to you explaining about the late food, or the wrong order, or failure to refill drinks than if you simply refusing to pay. Asking for it to be reduced will often work, because most restaurants want happy repeat customers more than they want a few dollars in tip.
Auto-gratuities are found in places where they find tipping is not being done to the restaurant's expectations. Tourist areas do it, but auto-gratuities for large groups are common if they don't believe those groups can work out tips for themselves.
Other than that, this sort of thing is just a cost of doing business in North America.