As hundreds of police officers hit the streets of Munich last month fearing a terrorist attack, Germany’s defense minister broke a national taboo: She ordered soldiers to prepare to step in.

After police found a lone teenage shooter, not a team of terrorists, killed nine victims and himself, the 100-strong army unit didn’t leave its base. But the minister’s unprecedented command, and three other acts of violence that shocked Germany in late July, are spurring debate about a World War II legacy.

Germany’s postwar constitution—intended to protect democracy after the Nazi era—forbids the army from deploying at home, except for defense against invasion or in case of natural disasters or extreme emergencies. Last week, Chancellor Angela Merkel, under pressure to reassure anxious Germans, presented a nine-point counterterrorism planthat included training the army to assist police in dealing with a terror attack.

“The time is ripe” for such a step, Ms. Merkel said.