They did, because the central government have refused to agree to talk with them. If the central government had played ball and allowed a real election over independence, then the whole thing wouldn't have happened.
Article 1.2 - Spanish Constitution: 'National sovereignty is vested in the Spanish people, from whom emanate the powers of the State.'
http://www.congreso.es/constitucion/ficheros/c78/cons_ingl.p...
In my opinion there are huge stresses in Spain that will open the can of worms that is redefining the Constitution during the next decades. Republicanism, decentralization, chunks of the constitution that nobody really puts in practice, etc. That wont happen in 2 days. But it can happen.