I'm the US church are tax exempt because the law doesn't apply to them, not because it does. the law applied to everything except the exempt things. the establishments clause is the reason, in the case of the church
remember also, this hasn't always been true. there didn't used to be these taxes
read the 501c
https://www.law.cornell.edu/uscode/text/26/501