The violence, which comes as Germany prepares for snap elections in February, has left the nation in mourning and its sense of security deeply shaken.