The shooter’s motive was unclear, but the authorities said it was not believed to be related to terrorism.