simple, the writers of the bill of rights did not extend the rule of the amendments to the states and localities. for instance: the state of massachusetts had a state religion for decades after the passage of the bill of rights. heck, the 10th amendment basically says that unless something is explicity prohibited the states by the constitution that its fair game.
The powers not delegated to the United States by the Constitution, nor prohibited by it to the States, are reserved to the States respectively, or to the people.
The text of the First Amendment expressly restrains "Congress", which was obviously the federal legislature, but is silent on state legislatures. However, the Constitution contains what some argue to be a 14th Amendment already 'built-in':
Section 2. The citizens of each state shall be entitled to all privileges and immunities of citizens in the several states.
This Constitution, and the laws of the United States which shall be made in pursuance thereof; and all treaties made, or which shall be made, under the authority of the United States, shall be the supreme law of the land; and the judges in every state shall be bound thereby, anything in the Constitution or laws of any State to the contrary notwithstanding.
The Senators and Representatives before mentioned, and the members of the several state legislatures, and all executive and judicial officers, both of the United States and of the several states, shall be bound by oath or affirmation, to support this Constitution; but no religious test shall ever be required as a qualification to any office or public trust under the United States.
For some reason, people couldn't read these rather forceful and unambiguous articles to contravene the position that since the text of the First Amendment doesn't expressly restrain the states, it therefore cannot be read to restrain them.
Which is partially correct, the First Amendment doesn't restrain the states, the aforementioned articles make binding upon them the restrictions imposed on Congress by the First Amendment.
But whatever, its a done deal now. The 14th Amendment makes this entirely academic.