An electromagnet is a coil of wire that becomes a magnet only when current flows. Grip the coil with your right hand, fingers along the current arrows — your thumb points to the N pole.
Make it stronger with more turns, more current, or a soft iron core. Reverse the current and the poles swap.
Iron multiplies the field hundreds of times, but it saturates at about 1.6 T. (This model uses μᵣ ≈ 200 for a simple core.)