The oxidation state of an element is based on its electronic configuration. The various oxidation states of a transition metal is due to the involvement of $(n-1) d$ and outer $n$ s electrons in bonding.
For example, ${Ti}(22):[{Ar}] 3 d^2 4 s^2$ can show three oxidation states $(+2,+3$ and +4$)$ in various compounds like ${TiO}_2(+4), {Ti}_2 {O}_3(+3)$ and ${TiO}(+2)$.
The non-transition elements mainly the $p$-block elements can show a number of oxidation states from $+n$ to $(n-8)$ where, $n$ is the number of electrons present in the outermost shell e.g., phosphorus can show $-3,+3$ and +5 oxidation states.
Lower oxidation states are ionic as the atom accepts the electron or electrons to achieve stable configuration while higher oxidation states are achieved by unpairing the paired electrons and shifting the electrons to vacant $d$-orbital.