Antiferromagnetically driven electronic correlations in iron pnictides and cuprates