It's a question of statutory or constitutional interpretation. There have been whole books written on the subject.
The basic rule is that the plain language controls. If there is an ambiguity, then resort to other sources is appropriate. In the case of the Constitution, those sources properly are the intent of the Founders, often amplified by contemporary practices at that time.
With legislation, courts sometimes resort to statutory history, provided by debates, hearings etc on a law.
Here we have a situation where the plain language is unambiguous. Subsidies are only allowed through state exchanges. The law's defenders claim the gran intent of cross subsidies in the law should take precedence, but there is no evidence the lawmakers intended this. In fact, there is substantial evidence the subsidies were designed as a carrot to induce states to set up exchanges.
Another argument has been that the courts should extend deference to the agency in charge of implementing the law. This rule however does not allow the agency to rewrite the law or to ignore inconvenient provisions.
This is yet another example of how poorly drafted and thought out the law is.