The universe was introduced to Cassian Andor in Rogue One murdering an informant named Tivik, so the Empire would not capture the informant. Tivik had in injured arm, which disabled him from climbing to safety from closing Imperial Stormtroopers. If Tivik had been captured, much of the Rebel plans would have been exposed to find Jyn Erso.
Cassian’s actions are highly problematic legally (let alone morally). First, Cassian killed Stormtroopers who asked for his identification. The Stormtroopers only asked for Cassian’s identification, which is highly difficult to justify the use of lethal force as a response. However, the Stormtroopers did not have reasonable suspicion to stop Cassian, as he was not apparently breaking any laws. Perhaps Cassian could have reasonably believed his life was in danger based on past actions of Imperial Stormtroopers, but this would still push self-defense laws well past the norm.
Tivik posed no direct threat to Cassian’s life. Killing Tivik would meet the legal definition of murder, because Cassian killed Tivik with malice aforethought, because there was an “intent-to-kill.”
Tivik had knowledge that could have been fatal to the Rebellion. If the Empire had learned of Galen Erso’s actions, or the existence of Jyn Erso, the Rebels would not have been able to develop a plan to find Jyn and ultimately the Death Star plans. Unfortunately for Cassian, the necessity defense does not cover killing people.
The street fight on Jedha witnessed Cassian shooting one of Saw Gerrera’s “extreme rebels.” Gerrera’s freedom fighter had an explosive device that objectively looked like he was going to throw the explosive at the disabled hover tank. As Jyn Erso was hiding by the tank to protect herself from the fire between Gerrera’s men and Stormtroopers, Cassian could argue he killed Gerrera’s soldier in order to protect Jyn from being killed.