The context of 2 Tim 3:1-9 speaks of people who were ostensible converts to Christianity, but whose deeds betray their spiritual folly. That is, Jannes and Jambres are mentioned in a context of believers who are hypocrites. Thus the context of 2 Tim 3:1-9 is not talking about unbelievers but of apostates, who make an ostensible claim to faith.
There is a passage in the Book of Acts that talks about Simon the magician (Acts 8:14-24), and which might help to better illustrate the mention of Jannes and Jambres in 2 Tim 3:8.
Simon the magician was an ostensible convert to Christianity. That is, he "believed and was baptized" (Acts 8:13). However, when he observed the laying of hands and the giving of the Holy Spirit, he offered money as if the bestowal of the Holy Spirit were a magic trick. (There is no mention that Simon had desired to receive the Holy Spirit.) The Apostle Peter had accused him of having no portion in the matter (i.e., no portion with God's Spirit). Simon was still "in the gall of bitterness and in the bondage of iniquity" (Acts 8:23). Apparently his outward conversion to Christianity had cost him his ability to perform sorcery and other magic arts, for which he had become very bitter. In so many words, Peter accuses him of never having been converted, since he warned him to repent from a heart that was not right with God.
We know that there is evidence from the Dead Sea Scrolls and other extra-biblical literature (such as the Targums) that Jannes and Jambres (or Mambres) were Egyptians reputed to have been magicians in the court of Pharaoh. The Apostle Paul may have been familiar with these Jewish traditions, since their names are not mentioned in the Hebrew Bible. We know from the Hebrew Bible that the Egyptian magicians had acknowledged that the power of Moses was indeed "the finger of God" (Exodus 8:19), and therefore they conceded defeat and stopped trying to resist Moses with their own magical arts. It seems that Jannes and Jambres (like Simon the magician in Acts chapter 8) were ostensible converts, and therefore had departed Egypt with Moses as part of the "mixed multitude" in Exodus 12:38. However, like Simon the magician, who was an ostensible outward convert, they were "rejected in regard to the faith" (2 Tim 3:9). Jannes and Jambres opposed Moses in the same way that apostate Christians (about whom Paul wrote to Timothy) had opposed the truth, and therefore were rejected in regard to the faith. Jannes and Jambres therefore had not opposed Moses as unbelievers in Pharoah's court, but as apostate believers in the wilderness (like Balaam, to whom these two men are also associated in ancient Jewish folklore).