Electromagnets work via the physics of electric fields having magnetic fields. (Measured in teslas)
This magnetic field can be intuitively modeled through the right hand rule. A coiled conductor, often insulated copper wire, will have a magnetic field where if curled fingers match the direction of current flow, your up pointing thumb will point in the direction of the north pole. This magnet is likely to be weak due to the magnetic field freely circulated around the wire. To have an effectively stronger electromagnet, you need to constrain the field.
This requires a permeable material, a ferromagnetic material, to act as a core. This core (usually an iron based alloy) has tiny magnetic regions that are disordered, cancelling themselves out. When a field interacts with these magnetic regions, they align to that field. More current will create a stronger field around the coil, causing more of these regions to become aligned with the field. Eventually, this will reach a saturation point, where further increases in current no longer meaningfully effect the usable magnetism. After current is removed, most of these magnetic domains will revert to their disordered state. Some of these domains will remain aligned, an effect called hysteresis, leaving the core a weak permanent magnet. This is unlikely to matter for us. If it does become a problem, you can degauss it by rapidly alternating current in the coil.
When designing your electromagnet (or deciding which one to use), you need to think of the magnetic circuit you need to achieve your goal. Think of what you want, then consider how to use the flow of magnetic fields to achieve that goal. Consider a voice coil actuator, you want it to smoothly, quietly, and efficiently move a load linearly. To accomplish this, you could wrap a coil of wire onto a tube of electrical steel (used for its high permeability and low hysteresis) with a neodymium magnet (high magnetic force relative to cost) in the center to move relative to the field. A spring would be added so that it would return to a resting state without requiring power. (Voice coils can have either the magnet or coil move. Usually the coil moves in applications where moving the load fast matters most, ie; speakers. Where the load must be heavier and controlled with greater stability, the magnet is moved, ie; gas control lines.)
It is important to always remember, the fields weaken with distance. You want your electromagnetic fields as close to the load as possible. This is why the space between a motors stator and rotor are tiny. Why the coil wraps around the magnet as closely as possible in speakers, etc..