Germany allowed very large numbers of refugees into the country, and the recent attacks have been men who had their applications rejected.
I suppose it’s a way of punishing the country for that situation.
Edit: I see above the police have said this is not an immigrant on this occasion. Then we fall into the second phase - the copycat attacks, as people have realised this is a way of killing people without accessing weapons.