If current passes through a solenoid, will two consecutive loops move towards or away from each other and why?
The loops would move toward each other due to the attractive force produced by the generated magnetic field.
When current flows through the loop of a solenoid, it is always flowing in the same direction, i.e. parallel, to the loops above and below.
We know that when two wires carry a current flowing in the same direction, the wires attract. This is due to the fact that each wire produces a magnetic force toward the other, which is attractive. We can reason this out using the right hand rule.
On the other hand, when the currents are flowing in opposite directions, the wires repel.