The democracy is based on the principle of the freedom of expressing one's thoughts, both individually and in groups. So, political parties are only one of the possible means to express your opinion in the collective way. The real democratic country allows free establishment of not only political parties, but any kind of social organization.
The democratic country has also the right and the obligation to protect its citizens from criminal and terroristic organizations. You are free to express the view that stealing should be allowed, but once you start doing that in practice, you're criminal. If your political party believes in banning private property, and in the same way practice economic redistribution on their own, they're called mafia.
So if there's a scene behind a political party, that is practicing violence and terror (and, to my knowledge, it was the case in Germany), delegalizing such a party is a countermeasure taken by the state that fulfills its obligation to protect its citizens.
But sometimes the ideology itself is forbidden. For example, if your political program foresees exterminating some social group, for example people taller than 1.90m, you would be forbidden in (almost) any democratic country, even if you say, they will be exterminated only after you take the power and change the consitution. Why? I'd argue, because democratic country is oblidged to protect all its citizens, even those who are so shameless tall, so they should be also protected by the consequences of the party wanting to kill them taking over the power.
Democracy is not about allowing people to do anything, for example kill, rape or steal. So it's a constant compromise between your freedom and the freedom of the others.