I think you're forgetting differences in military capabilities.
Israel can be more selective in it's targets in Gaza, but they deliberately chose hospitals. Iran, the nation defending itself, has to send large missile barrages to try and break through the iron dome defense. Those will be less precise