Why do north and south poles on magnets change back and forth?
Only electromagnets can change back and forth and then only when they are connected to a supply of alternating current. A permanent magnet, such as that used to hold notes to a refrigerator, has permanent poles that do not change. But an AC powered electromagnet, such as that found in a transformer, does have poles that change back and forth.