In your second code snippet you are creating a Python Generator, which will be lazily evaluated.
Your code works, if you execute the generator or use a list comprehension instead.
resnet18 = models.resnet18()
for param in resnet18.fc.parameters():
    print(param.requires_grad)

# 1
gen = (p.requires_grad_(False) for k,p in resnet18.fc._parameters.items())
next(gen)
next(gen)
# 2
list((p.requires_grad_(False) for k,p in resnet18.fc._parameters.items()))
# 3    
[p.requires_grad_(False) for k,p in resnet18.fc._parameters.items()]

for param in resnet18.fc.parameters():
    print(param.requires_grad)