Imagine I was born in country X at xxxx. At xxxx+20 years country X is annexed to the United States. (Freely or forcefully) At xxxx+40 years I am elected to be the next president of the United States.
Can I legally be elected?
The term “natural born citizen” appears as a qualification for serving as President or Vice President under Article II of the U.S. Constitution. It includes U.S. citizenship acquired at birth under both federal constitutional and statutory citizenship law.
Prior to advent of the 14th Amendment all Presidents were “natural born citizens” only if they acquired citizenship “at birth” under a federal statute. In modern times, Barry Goldwater, John McCain and former Governor of Puerto Rico Luis Fortuno were all deemed eligible to run for President or Vice President as “natural born citizens” based on federal statutory birthright citizenship. The same is true of any other presidential candidate who acquired citizenship “at birth” to a U.S citizen parent outside the U.S. or in a U.S. territory in which Congress has conferred that status.
Goldwater, as one example, was born in the Territory of Arizona in 1909 before it became a state in 1912. Upon Arizona's confirmation as a state, Goldwater became a citizen at birth.
If Country X is granted statehood, then you will be eligible to be elected President. If it is merely a possession or territory, then not.
At the time of annexation of country X someone would have to decide the status of the countries citizens: If all citizens of X are now citizens of the USA, and whether they are legally citizens from the date of annexation or since they were citizens of X, and if they are considered residents in the USA since the day they became residents of X, and if they are retrospectively "born in the USA" if they were born in X. And other things, like whether non-citizen legal residents of X are now non-citizen legal residents of the USA.
That has to be decided for many reasons, and the answer to your question follows naturally from this. Maybe you could check on a history site if anyone knows how this worked with Hawaii.