Why do two parallel wires with currents in the same direction attract?
Two parallel wires carrying electric currents in the same direction attract each other due to the interaction between each wire's current and the magnetic field produced by the other.12
According to Ampère’s law, an electric current creates a magnetic field that circles the wire. When two wires are placed parallel to each other, the current in the first wire generates a magnetic field at the location of the second wire. Because the currents flow in the same direction, the right-hand rule dictates that the magnetic field produced by one wire exerts a magnetic force on the moving charges within the second wire.13
This force is a manifestation of the Lorentz force, which acts on moving charges in a magnetic field. For parallel wires with currents in the same direction, this interaction results in an attractive force between them. Conversely, if the currents flow in opposite directions, the resulting force is repulsive.4312