WASHINGTON — At his star-spangled Independence Day extravaganza this month, President Trump singled out Gene Kranz, the legendary Apollo flight director. “Gene,” the president said, “I want you to know that we’re going to be back on the moon very soon — and someday soon, we will plant the American flag on Mars.”

What could be more American than vowing to go to the moon and beyond on the Fourth of July? For Mr. Trump, it was a chance to channel his inner John F. Kennedy, who first made the moon the nation’s goal — to make the sort of bold promise that appeals to his own sense of greatness and to wrap himself in a part of Americana akin to baseball and apple pie.

But Mr. Trump is the 10th president since Kennedy to put his stamp on the space program and the latest to aim for the stars with more brio than blueprint. After the Apollo program ended, other presidents promised to go back to the moon — or send humans to Mars or even land astronauts on asteroids. None did, unwilling or unable to obtain the financing necessary, and it remains uncertain whether Mr. Trump will, either.

As the nation on Saturday celebrates the 50th anniversary of the Apollo 11 landing, the story of presidents and space exploration in the subsequent five decades is one of fascination, frustration and futility, an unrequited romance as star-struck chief executives dreamed of recapturing the magic of Kennedy’s moonshot without summoning the resources or the national will that made it possible in 1969, almost six years after his death.