I can't imagine any of the presidents since I've been alive that would have done it, but he did it, so good for him. Seems only prudent to believe he only did it for some type of political reasons rather than sincerity.
I'm not sure I would use the word "only". It was very possibly a mix of both. He says he's worried about getting to heaven. We should all share that "worry".
Life is complicated, and very often mixed motives are at work in people's behavior. It all gets sorted out eventually.