Apart from the storm of comments, let me just try to answer the question. 

There are several ways in a which a mathematical theorem
can be contingent.

 - First, the independence phenomenon in set theory shows the striking ubiquity of
 contingency in mathematics. For example, the Continuum Hypothesis is true
 is some set-theoretic
 worlds and false in others (and we can control it
 exactly). There are hundreds of other examples of
 statements with the same independence status---they are
 true in some worlds and false in others. The method of
 forcing has been used to spectacular effect in proving
 many of these independence results.

 - The Incompleteness phenomenon of Goedel can be used to show that
 whether a statement is provable or not from a given
 axiom system (in classical logic) can be contingent.
 Specifically, the Incompleteness theorem says that no
 theory T, if consistent, can prove its own consistency.
 Thus, if ZFC is consistent, then there are models of ZFC
 in which ZFC is thought to be inconsistent. In such a
 model, ZFC is thought to prove any statement at all! But
 in our world, not all these statements will be theorems.
 Thus, in this sense, even the question of whether a given statement is a theorem or not
 can be contingent.

 - The large cardinal hierarchy in set theory provides
 numerous examples of statements transcending the
 consistency strength of weaker statements.

There are also several ways in which contingency is ruled
out.

 - First, one of the most important properties of a proof
 system is <em>soundness</em>,
 which means that any statement provable in the system from
 true hypotheses will remain true. Of course, this is an
 expected feature of any proof system worthy of the name. A
 *theorem* is a statement having a proof in such a system. Once we have adopted a
 given proof system that is sound, and the axioms are all
 necessarily true, then the theorems will also all be necessarily
 true. In this sense, there can be no contingent theorems.

 - Second, one of the profound achievements of Goedel was
 his *Completeness theorem*, which states that any
 statement that holds in all models of a given first order
 theory T, actually has a proof from the theory. For
 example, every statement in the language of group theory
 that happens to be true in all groups, actually has a
 finite proof from the group axioms (using any of several
 proof systems). This is  far from obvious, and I find it profound.
 But it answers a dual version of a question you might
 have asked, which I find interesting, namely:
 Is every necessary truth a theorem?
 The answer is Yes, and this is just what the Completeness
 theorem expresses.

These last two points together explain that if one takes the possible worlds to be all models of a given theory, then the necessary truths are precisely the theorems of that theory.