They're not always in a different state. If you live in California, you pay sales tax on online purchases pretty much always.
However, in California, even if you only have a physical presence in some remote part of northern CA, suddenly that affects your ability to sell to 37 million other people.