The reason that these entities are able to offer their online casinos to you is because they are not only licensed outside of the United States, but also that they are physically located outside of the United States. These casinos are licensed, of course, licensing requirements can be a little lacking in some jurisdictions they are just not regulated by your state.
Of course, for those states without regulated online casinos, or even for some of that states that do have, there are a wide variety of unregulated online casinos operators willing to allow players from your state to play. What is true is that almost all states, perhaps even all of them, have laws against operating a casino within that state that is not licensed and regulated. To some extent, there had always existed a misconception that any online casino not specifically licensed and regulated by an individual state was automatically illegal to play at, but this is not true. Contrary to popular opinion, gambling online in the United States of America was never illegal at the Federal level of Government.