Christians have always had much more in common with Jews and Muslims than they’ve ever had with secularists, including segregation and dress codes for worship.
It was mandated in the 1917 Code of Canon Law. Canon 1262 states:
1. It is desirable that, consistent with ancient discipline, women be separated from men in church.
2. Men, in a church or outside a church, while they are assisting at sacred rites, shall be bare-headed, unless the approved mores of the people or peculiar circumstances of things determine otherwise; women, however, shall have a covered head and be modestly dressed, especially when they approach the table of the Lord. [Source: Catholic.com]