And the main force behind the Hays Code was the Catholic Legion of Decency and the very real threat that US Bishops would call boycotts on movies that broke the Code.
https://www.churchmilitant.com/news/article/the-legion-of-decencyhow-american-catholics-fought-hollywood-and-won