The suspect, a former asylum-seeker who was supposed to be leaving Germany, was arrested after the attack on Wednesday.