If we do engineering work in states where we don't have an office we still have to file a tax return with that state and pay taxes on earnings we accrued there.
I know athletes/performers have to file income tax returns with every state they play in.
I highly doubt car companies are any different, if Tesla sells a car in a state they don't have an office it I would bet a lot of money on the fact they will have to file for revenue taxes in that state.
How do automakers file taxes when they make sales to dealers? The consumer already pays the sales tax, unless they defer that to the dealer, who then pays it for them, on the final sale. The automaker would still be paying the same taxes on profits made by selling cars, except the state would lose the tax from the profits of the dealerships.
The problems with completely eliminate dealerships goes beyond tax reasons though. If there is no local (or reasonable local) certified dealership, where are you supposed to get your car serviced for recall and warranty issues? Or even serviced by someone you know is certified to assess that specific brand of car? There aren't exactly Tesla certified mechanics advertising as such, and every dealership has one.
I think banning direct sales is stupid though. We don't ban Apple from selling iPhones or Panasonic from selling TVs.