They charge tax based on where the item is shipping. I believe online stores only have to charge tax in states where they have a retail presence. So in theory if you lived in a state with no brick and mortar Apple Store, you might not be charged tax.
I’m only speculating as I live in California so I don’t have any first-hand experience with ordering from another state.