For the DC current, when you change the direction of the current in a electromagnet the North and South pole of the electromagnet will reversed with the AC current, it constantly changes its current direction, hence the North and the South pole will change continuously too