The Latvian national also admitted to starting a fire in his home in Flums before the attack, the St Gallen prosecutor's office said on Thursday, according to the Swiss news agency SDA.
The teenager went on the rampage in the eastern Swiss town on the evening of October 22nd, attacking eight people and injuring six.
The victims included a young couple and their baby that was hurt as it fell from its pram.
The youth, who had no criminal record, said he had chosen his victims at random.
He carried out the initial attack near the post office in the northeast Flums, injuring a couple who were out walking with their baby.
He fled the scene in a stolen car and later injured several people inside a petrol station shop, where he was shot by police and apprehended.
Three people who were admitted to hospital as a result of their injuries have now been released.
The teenager, who was injured as the police sought to apprehend him, has been in detention since being released from hospital on October 26th.
He will stand trial next year on charges including attempted murder.