The Inductor as an Electromagnet
A coil acts as an electromagnet. It generates an attractive force like a bar magnet. The intensity of the force is proportional to the coil current. The intensity and direction of the magnetic force are set by the amplitude and sign of the current. The effect of the electromagnet can be controlled.
Magnetic field
The coil current causes a magnetic field. A field describes the action of a force in space. The field can only be detected through this action of force. If you hold a compass needle in a magnetic field, the needle aligns itself in the direction of the field, because a force acts on the needle in that direction. The effect of the field is described graphically with the help of field lines. Field lines are arrows that run along the direction of action. The more densely the field lines are drawn, the more intense the field is at that point in space. The following figure shows, in greatly simplified form, the field of a bar magnet using a few field lines:

Magnets have a magnetic north pole and a magnetic south pole. Unlike poles attract each other, like poles repel each other.
The field of a bar magnet acts everywhere in space. Its intensity decreases with the distance from the source. A compass needle will align itself differently at every point in this field. It always points in the direction of the field lines. The action of magnetic forces in fields can also be shown with iron filings, which align themselves along the field lines. See the following link (in German) with good graphics.
Magnetic flux
The magnetic field is described mathematically by the magnetic flux. The magnetic flux generates the magnetic force. Without derivation, the magnetic flux of a coil is:
The magnetic flux depends on the number of turns N, on a material parameter and on geometry parameters. These are the same parameters that also describe the inductance of the coil. The following applies
The magnetic flux is in phase with the current. It has the same waveform without a time shift. It can be described as a kind of magnetic current that acts similarly to the electric current. Magnetic fields are complex; I do not go into them any further here. At this point, please simply note that there is a magnetic flux that produces the magnetic force of the electromagnet.
Direction of the magnetic field
The following direction convention applies between the direction of current flow and the polarity of the magnetic field:

We look at the core, at its cross-sectional area. If electric current now flows through the coil anticlockwise, a magnetic north pole forms at this end of the coil. If you look at one end of a coil and electric current flows through it clockwise, a magnetic south pole forms there.
In general: let us grasp the turns of the coil with the right hand. The fingers (except the thumb) are aligned along the turns in the conventional current direction. The thumb then points in the direction of the magnetic north pole of the coil.
Magnetic induction
The coil not only generates a magnetic field; it is also influenced by magnetic fields. A changing magnetic field induces a voltage in the coil. The faster the change in the magnetic field, the higher the voltage. The stronger the intensity of the magnetic field, the greater the voltage. The voltage of the coil is determined by the magnetic field present in the coil core. In general:
This equation is called the law of induction for a coil. It can be verified experimentally. If a bar magnet is moved near a coil, its magnetic field in the coil core changes. A voltage U can then be measured at the coil terminals.
The field in the core can also be the field that the coil itself has generated through the coil current. Then:
That was the derivation of the inductor equation from the fundamentals of electrical engineering with the help of the magnetic flux. Please also read this good Wikipedia article.
Summary
The coil generates a magnetic field when current flows through the windings. A voltage is induced at the coil terminals when a time-varying magnetic field is present in the core. Either the field in the core is generated by current flowing through the wire of the coil. If this field varies over time, it induces a voltage in the coil. Or an external magnet is moved near the coil, so that the magnetic field in the core changes over time and a voltage is induced. Both effects can also be superimposed.