There are some jurisdictions in the US in which gambling is legal (Reno, Lake Tahoe and Las Vegas in Nevada, Atlantic City in New Jersey and any number of Native American reservation-based casinos spring immediately to mind). If the sites are for casinos, for instance, that are headquartered and do offline business in these areas -- and either limit online gambling to people who are physically located in one of these legal-gambling jurisdictions or don't allow online gambling at all (rather simply offer information about the offline businesses) -- then I would think the sites are legal. (Of course, I'm not a lawyer, so take my opinion with the proverbial grain of salt...)
These legal casinos are big business, and it's quite common for them to be audited by some of the biggest names in the CPA world. But, again, they're legal within their local jurisdictions and are careful to comply with all applicable laws.
Some other sites, frankly, skirt the fringes of the law -- maybe legal, maybe (probably) not. Offering online gambling to anybody who's got a credit card and a modem, no matter where they're physically located, that sort of thing. Most of them do things like registering their company and hosting their site outside the USA, in a country where gambling is legal, no matter where the site owners actually may live. They hope they'll make a bundle quickly before the US authorities track them down, and hope they'll be able to hide away and hang on to enough of their loot to make it profitable in the end. And to be honest, there's enough money to be made in gambling that some folks consider it worth the risk.