Those were two very different cases. Czechoslovakia was a consensual separation. Yugoslavia was not.
The Yugoslav state was ultimately held together by 1) the strength of Marshal Tito, his Communist Party, and his legacy and 2) specific agreements that balanced political power among ethnic groups. Both of those broke down slowly after Tito died. When the country started to fragment, war broke out as various groups tried to resolve longstanding differences through the force of arms.
The Spanish central government has made a fundamental error in completely suppressing the vote. They could have downplayed it, and considered it akin to a straw poll. Based on what I have seen, it would have likely not passed. By suppressing it through force, they are hardening opinions and making matters much worse.