Effect of Compactified Dimensions and Background Magnetic Fields on the Phase Structure of SU (N) Gauge Theories