It's impossible to separate civilian and military targets in Gaza by design. That building also contained Hamas offices. Hamas intermixes with the civilian population to generate the maximum number of civilian casualties when Israel attacks.
Israel did one thing to try to prevent injuries to civilians: They spread warnings about a ground invasion to get all the Hamas soldiers into their underground tunnels. Then they bombed the tunnels with ground-penetrating weapons to blow them up. They knew Hamas would not let civilians into their tunnels.
We're flying electric helicopters on Mars yet you can't turn on your clothes dryer in Texas. That's because scientists are in charge of Mars, and Republicans are in charge of Texas.