I want to know how an AC electric magnet works since the polarity of an AC current changing 100 times in each second (for 50Hz mains supply) so its magnet polarity(N & S) also will changed 100 times in each second. But i see AC solenoid always moved in one direction when the power is connected, why?
A solenoid core isn't a magnet itself but instead a simple iron piece. Such an iron piece "gathers" the magnetic field lines which come from the coil. When the iron core is not centered inside the coil, the magnetic field lines are longer than they could be, which results in a force to change that.
a) coil without core → field lines long and wide. High magnetic resistance.
b) core not entirely in the coil → field lines shorter and "gathered" into the core as the magnetic resistance is lower there.
c) core centered in in the coil → field lines shortest and a bigger part of it running in the core so magnetic resistance is even lower than in b)
That's the reason why the core is moved into the coil. Because when it's centered inside the coil, the field lines are shorter and magnetic resistance is much lower. As this doesn't depend on field direction, an iron core is always moved into the coil, making it work with both AC and DC applied to the coil.