How Does an Electromagnet Work? | Step-by-Step Explanation