The easiest answer to this question is that the Phil Coulson in AOS was a Skrull sleeper agent all along. Sometime after the events of
Captain Marvel, the real Agent Coulson was taken captive by the Skrulls and replaced with a doppelganger. My guess is that the switch was made between
Thor and
The Avengers since Thor's arrival on Earth caused SHIELD to experimentation with the Tesseract, which Thor claimed alerted alien races that Earth was "...ready for a higher form of war."
Once the Skrulls detected the Tesseract's power signature, they abducted the real Coulson and replaced him with a warrior who had been genetically altered to appear identical to a human down to the cellular level. Skrull!Coulson also had Real!Coulson's memories implanted in his mind and his own memories repressed. The doppelganger's shapeshifting and genetic changes prevented him from transforming back into his natural form when Loki killed him and also allowed him to be revived by the infusion of Kree blood/serum that reanimated him. His lack of a family and assignment to work with the AOS team helped his cover because very few people knew him well enough to detect the scam.
Unfortunately, the Skrull commanders never activated Skrull!Coulson for some reason, leaving him to his fate on Earth. The real Phil Coulson remains locked in a cryo-vault on the Skrull throneworld, awaiting the day when someone, anyone, realizes that he's been replaced.
And that's how the
real Agent Coulson can return to the present-day MCU.