The bug
A villager summons a firework on the ground and another villager is standing somewhere tall, when the firework has reaches the exploding height it will just damage that villager standing high making the golem hostile to that villager, there's also a chance that villager will summon it inside a building so and then that makes the iron golem to attack the villagers.
This works in other mobs too.