How can iron have two oxidation numbers?
It's important to note that many elements have multiple oxidation states. In chem class - you typically just learn the most common ones.
For example, calcium normally forms +2 ions, but it is possibly (but rare) that calcium can form compounds when the calcium has a +1 oxidation state.
So why can iron form both a +2 or a +3 oxidation state? Both will give better stability then the ground state electron configuration for iron.
Ground state: [Ar]
+2 ion: [Ar]
+3 ion: [Ar]
What is your take home message? Ions form because they give better stability than ground state atoms, but not necessarily perfect stability.
The two ions of iron both give better stability to the particle.