Bismarck believed that both draw allegiance of the people away from the German state.
To say that Bismarck was a nationalist, that would be an understatement. Bismarck believed that loyalty to the state comes before everything else including religion. He was especially against socialism as he saw it as something not German and thus dangerous. That is why he tried to limit their influences as much as he could.