Connecting two electromagnets against each other to study self-inductance
The coils in a 'U' shaped electromagnet are equivalent to a single coil, because they are magnetically coupled via the connecting bar at the bottom. The bar is made of a high permeability ferromagnetic material such as iron or steel. This provides an easy path for the magnetic flux to get from the end of one coil to the start of other, and (combined with the magnetic cores the coils are wound over) reduces the external magnetic field around them. 

So even though the external fields in your first drawing are going in different directions and so should be cancelling each other (reducing the total inductance) this effect is swamped by the better flux coupling through the bar. If you imagine bending the bar 180º so the two coils are in line, you will see that the winding continues in the same direction in both coils. As result the total inductance is doubled (compared to two independent coils which are not magnetically coupled) because the flux produced by each coil also goes through the other. This effect is called mutual inductance.  



In your second drawing there is no connecting bar, so you simply have two independent electromagnets wired in series. Since these are wound in opposite directions, if placed beside each other their external magnetic fields will add and increase the total inductance - but only by a small amount because each coil's inductance is dominated by its strong internal flux, and the permeability of air is low so external flux coupling is weak and drops off rapidly with distance.