"Fulfillment", a novelette by A. E. van Vogt. You may have read it in one of these compilations, some of which can be borrowed (for free but registration required) from the Internet Archive.
Here is a plot summary from MPorcius Fiction Log:
This story is a first person narrative told in the voice of a super computer that has achieved self-awareness. At the start of the tale, the computer sits on a hill in the far future, on a desolate Earth bereft of people and even atmosphere. An opportunity to travel back in time presents itself, and the computer explores the twentieth century. It has a battle of wits with another computer (Van Vogt readers will perhaps not be surprised that this other computer is, in fact, its own younger self), meets its creator, and solves the mystery of what happened to the Earth's atmosphere and population.
"Fulfillment" has a philosophical point to make. At the beginning of the story the computer is selfish and merciless, and also dissatisfied, living a life without meaning, wondering what its purpose could be. At the end of the story it finds satisfaction in working in partnership with others, putting its abilities to use for the good of a community. There may be a note of tragedy, though; we know that after helping humanity achieve the stars and immortality, that the computer will be abandoned on the dead Earth.
It is told in the first person by an intelligent machine:
I sit on a hill. I have sat here, it seems to me, for all eternity. Occasionally I realize that there must be a reason for my existence. Each time, when this thought comes, I examine the various probabilities, trying to determine what possible motivation I can have for being on the hill. Alone on the hill. Forever overlooking a long, deep valley.
The machine has survived a sort of apocalypse:
Each day the sun comes up over the airless horizon of Earth. It is a black starry horizon, which is but a part of the vast, black, star-filled canopy of the heavens.
It was not always black. I remember a time when the sky was blue. I even predicted that the change would occur. I gave the information to somebody. What puzzles me now is, to whom did I give it?
[. . . .]
What happens to Earth's atmosphere is a phenomenon of Nature, an alteration in the gravitational pull of Earth, as a result of which escape velocity is cut in half. The atmosphere leaks out into space in less than a thousand years. Earth becomes as dead as did its moon during an earlier period of energy adjustment.
It can create human-shaped constructs:
I wait till he is out of sight, and then set up a category of no-space between the main body and the human-shaped unit—with which I had just confronted my visitor. Because of the smallness of the unit, the energy I can transmit to it is minimum.
At the beginning of the story the viewpoint machine travels back through time from the far future to the near future, not under its own power but as a hitchhiker:
I am unable by myself to move through time. Long ago I solved the problem of how to do it and was almost immediately prevented from developing any mechanism that would enable me to make such transitions. I do not recall the details.
But the energy field on the far side of the valley has the mechanism. By setting up a no-space relationship with it, I can go wherever it does.
The relationship is set up before it can even guess my intentions.
The entity across that valley does not seem happy at my response. It starts to send another message, then abruptly vanishes. I wonder if perhaps it hoped to catch me off guard.
Naturally we arrive at its time together.
The AI from the future considers its past self an enemy and tries to destroy it, until it realizes the relationship:
The truth has already been verified by my integrating interoceptors. The Brain and I are one—but thousands of years apart. If the Brain is destroyed in the twentieth century, then I will not exist in the thirtieth. Or will I?
I cannot wait for the computers to find the complex answers for that. With a single, synchronized action, I activate the safety devices on the atomic warhead of the guided missile and send it up to a line of barren hills north of the village. It plows harmlessly into the earth.