Ok so here is what happened, I was playing a survival world with my friend. Shortly after we spawn in, we find a village. So, we head to the village, and I see an iron golem. So, I decided to kill it. So, I build a 4-block pillar and start attacking it. 3 seconds later it hit me off of the pillar even though I built a 4-block pillar so I run into a villager house and wait till he stops trying to attack me 5 seconds later I was greeted with the death screen I was confused because I was safe inside the villager house. So please if anyone can explain this please do.