Copenhagen police said a man shot dead by officers was responsible for two fatal attacks that shocked the normally peaceful Danish capital.