Doctor Strange is the 19th movie of 24 in the Marvel universe chronology. So there are 18 movies before this one which might be why that ending didn't make sense. This guide might help: https://editorial.rottentomatoes.com/guide/marvel-movies-in-order/