Yeag, if you had a law that said all elections were on Sunday, that could in fact be thrown out because it affects Christians who observe Sundays. The law doesn't need to specifically mention the religious group who is negatively affected to be unconstitutional.
It's a little more complex than that.
The traditional test is the Lemon Test, which states a law must meet three prongs to not run afoul of the Establishment clause;
The statute must have a secular legislative purpose. (Also known as the Purpose Prong)
The principal or primary effect of the statute must not advance nor inhibit religion. (Also known as the Effect Prong)
The statute must not result in an "excessive government entanglement" with religion. (Also known as the Entanglement Prong)
You can make arguments here against both the purpose and effect prong. The effect of a ban that targets specifically Muslim majority countries can be seen to have as it's main effect an inhibiting of religion, by preventing the movement or immigration of Muslims. This is a fairly hard case to make though.
What we have instead is judges finding that there is no legitimate secular purpose to the law. This is completely extraordinary.
Remember that it isn't saying the intended purpose isn't legitimate, it's saying there
is no legitimate purpose for this law (or, at the least, none put to the court by the defence or any amicus brief filed; expect dozens of such briefs ahead of any appeals). They hold that the administration's claim that the law has a national security purpose is absolute hogswash and there is no other purpose to this other than religious discrimination.
They are using the administration's statements and actions as evidence of this. That the executive didn't consult national security advisors about the details of the ban counts against them, as are the various statements of officials and spokespeople. They are basically saying that Trump has shown his arguments to the court can't be trusted and can in fact be ignored. This is a complete flip from the usual deference given to the executive on matters of national security.
A lengthy legal analysis and discussion on Lawfare;In this scenario, there are really two presidencies for purposes of judicial review: One is the presidency when judges believe the president’s oath—that is, a presidency in which all sorts of norms of deference apply—and the other is a presidency in which judges don’t believe the oath. What we may be watching here is the development of a new body of law for this second type of presidency.
This, we suspect, is the true significance of all of the references in both district court opinions to the many statements made by Trump and his aides about the Muslim ban and the true purpose of the policy effectuated in both orders. These references present, of course, as discussions of whether there is truly a secular purpose to the policy in an Establishment Clause analysis using the Lemon test. But there’s at least a little more going on here than that. The lengthy recitations of large numbers of perfectly objectionable presidential statements about Muslims coexist with a bunch of other textual indicia showing not merely that the judges doubt Trump’s secular purpose but that they doubt the good faith of his purpose at all—indeed, that they suspect that he is simply lying about his own motivations.
It's hard to see the decisions made standing up in appeals courts, let alone SCOTUS - especially the Hawaii case on grounds of standing - but judges who do buy into the argument that this president can't be trusted may well also agree with the reasoning here and find enough cause to strike down the law. It largely destroys any effective defence of it the administration can mount, giving groups like the ACLU a much stronger hand.