The Constitution doesn't care what religion a President is, it only cares that the Country is not under the control of any religion (or Church). The founders were ensuring that the US wouldn't be similar to Europe (at the time) where the Church controlled the State(s) and it's rulers, persecuted people, etc.
It had a lot to do with England it's kings getting and the then corrupt Popes & their constant meddling for their own greedy purposes. Also the Papacy could be bought in those days and Popes could give New World áreas as possessions to various princes and kings.
Once self determinant, the colonists ensured that no monarchy or Church could overrule or overtly influence elected leaders.