The incident came hours before Munich was to host a conference of world leaders, and before Germany’s federal election.