to grant a tax exemption to churches. In other words, it is a question of how the Constitution constrains the government, not how or whether the Constitution constrains churches (which it doesn't).
And getting back to the original point, churches are not prohibited under the law from engaging in political activity or even from campaigning for a candidate. The Constitution doesn't prohibit them from doing that and statutory laws passed by Congress don't either. The are free to engage in that but their tax exempt status will hinge on exactly how they do or don't.
So a church is free to campaign openly and directly for or against a specific candidate. If they do so then they will not qualify for tax exempt status. But they will still be a church, just a taxable church.
A church is also free to refrain from campaigning and in that case they will qualify for tax exempt status.
The above rules are part of the Internal Revenue Code. They are permitted by the Constitution but they are not required by the Constitution. There is no Supreme Court ruling saying that a government (state or federal) is required to provide tax exemption. The rulings merely say that they are permitted to provide tax exemption (but only in limited ways). The Constitution's role in this matter is one of limiting government; it does not limit churches.