He became the Sorcerer Supreme after The Ancient One died in his first movie. She was the Sorcerer Supreme at that time and when she died the Spirit of Vishanti passed from her to him. The Vishanti are an ethereal, ancient, magical godlike race of aliens who are the source of all the sorcerers' power. That's the book they were after in the movie, "The Book of Vishanti". That contains all of their collective knowledge and spells.
Then when he battled Dormamu by trapping him in a time loop it's implied that it may have gone on thousands of times before Dormamu gave up, and in the process Strange became a very capable Sorcerer himself through so much repetition. He basically leveled up big time in his fight with Dormamu.
Wanda is different. She's The Scarlet Witch and witches derive their power from Chthon, an extradimensional demon, and his book is the Darkhold. Wanda is basically Chthon's "Sorcerer Supreme". I think those demons in that temple drew a little inspiration from Chthon in the comics.
View attachment 56059
When Strange got snapped the spirit of the Vishanti left him and passed on to Wong. Technically Wong should be more powerful than Strange now because the spirit gives the Sorcerer Supreme a pretty big boost in the comics. It doesn't look like they went with that in the movie tho because Strange seemed just as powerful as Wong, if not more.