I know that this won't be the be all end all answer to this question. However, based on the information online there are no concrete answers in regards to how SaaS companies are taxed and where they pay their taxes too.
Same as any other entity (or person).
Entity pays taxes in it's domicile jurisdiction.
Best you talk with a tax preparer in your home country to ensure you have all the details.
And... If you're a US citizen + your SAAS company is generating massive cash, likely best to organize your entity in a low tax jurisdiction, like Bermuda which is home to Google, Intel, Verizon, etc.
And... best wait till Trump's new tax bill passes. If he has his way, corporate taxes may drop to a point low enough to keep your business in the US.
Great question, when it comes to business federal taxing they are taxed as any other but as a virtual service provider (non-physical) every state has a different law on that. The general idea is that some states don't have an import or sales tax law and or out of state law - so technically speaking you may have to file taxes completely differently than any other business out there because each state may vary.
If you end up having to send a tech to that area, you may have to to file especially for that state - I'm not a tax professional and you may have to talk to a tax expert in this field. One of the tax preparers I trust is Perla, she owns a bookkeeping & tax service - firstname.lastname@example.org
As an example, when I file taxes because provide consultancy services that are not physical or create software that does not transfer to any physical object I don't have to file separately on states unless I happen to send something to them - then I would have to file for that state.
One thing that is missing from other answers is cash vs accrual accounting. Cash accounting is typically only done by small businesses and ones that do not have the same timing challenges as a SaaS company. The largest difference is the cash received from a customer and the deferred revenue created. As a simple example... You have one customer who pays you $1 million on July 1 for 12 months of service. Let's further assume your operating expenses and cash paid for this 12 months of service is $700k (ratable monthly). As a cash payer would record in year 1, the taxable income of $650k and a loss of $350k in year 2. An accrual tax payer would have taxable income of $150k in both years. There are other financial statement impacts, from converting from cash and accrual accounting methods.
Taxes are assessed at 3 levels: federal, state, and municipal. We will disregard employment and sales taxes for these purposes. Broadly speaking, you will not have to pay full double taxation in two countries. The taxes paid to the foreign country will receive a credit or a deduction by your home country. Secondly, international sales can involve transfer pricing to a subsidiary which will impact the profitability in the foreign country. This is the point where you will want to consult a tax professional who is familiar with your product and the tax regulations of the countries you are doing business with.