In fact I thought it was illegal for employers to ask.
RAZD,
Religious institutions have the right to discriminate in hiring.
Title VII of the Civil Rights Act of 1964 acknowledges the appropriateness of allowing employers (including educational institutions) controlled by religious organizations to hire only members of that religion 42 USC 2000e-2(e). Similarly, Title IX of the Education Amendments of 1972 provides an exemption to educational institutions controlled by a religious organization whose tenets conflict with the requirements of Title IX, and the Americans with Disabilities Act permits religious entities to give preference in employment to individuals of a particular religion and permits such entities to require applicants and employees to conform to the religious tenets of the organization. 20 USC 1681(a)(3); 42 USC 12113(c).