As shown in image 1, you can see the almost complete structure for spawning an iron golem. However, if, before placing the pumpkin, you place a "block," such as, in this case, short grass, right next to the iron block that is in contact with the ground, the golem will not appear as shown in the second image, even though the pumpkin is already in place. However, if you simply remove the short grass and replace the pumpkin, as long as the iron structure is in a clear area, the golem will spawn without any problems
I think that this issue it's not necessarily a bug, because I can understand that a block "stuck" in the way can prevent the golem from spawning, but it's also true that there can be decisive moments that are affected by something as simple as some short grass that was right next to the iron blocks
Whether it's a bug or intentional, I wanted to write this report anyway
This ticket duplicates MC-60792