There was no evidence so far pointing to a religious motive, they added, despite the suspect reportedly yelling "Allahu akbar."
The 27-year-old unemployed carpenter, Paul H., used a survival knife Tuesday to stab and slash his four victims at Grafing railway station east of Munich.
"The investigating judge of Munich district court has ordered that the accused today be temporarily placed in a psychiatric hospital," said Bavarian police in a statement.
"According to a preliminary evaluation by a medical expert, the offender has a mental illness, and there are strong reasons to believe he committed the acts in a state of insanity or at least diminished criminal responsibility."
The barefoot assailant shouted "Allahu akbar" (God is greatest) and threatened to kill "non-believers", sparking initial fears of a jihadist attack, but police who detained him quickly said he appeared to be mentally confused.
It has since emerged that the man had spent Sunday in a psychiatric ward in central Hesse state but had left there on Monday morning.
He then caught a train south to Munich where, surveillance camera footage showed, he spent the night at the central railway station and then at Grafing, where he launched his dawn attack.
Police said they were evaluating mobile phones and disks found in the man's backpack and his home, adding that so far "no evidence has been found that would point to a religious motive" for the bloody attack.
By Wednesday, the steps to the train station were covered with flowers and candles for the victims - a 56-year-old man who died, and three other men aged between 43 and 58 who, police said, were now all in stable condition.
"Warm sympathies to the relatives and friends of the deceased and the injured," read one condolence card placed on the station's steps. "We suffer and mourn with you."