The teenager who shot dead nine people at a Munich shopping mall spent a year planning the rampage and "very likely" bought his weapon on the darknet, officials say.