Trying to understand flyback diodes and general diode orientation
Looking at figure two, the polarity has been marked such that, if you hooked it up to a battery like that, current would flow.

In figure one, the diode is reverse biased by the power supply, and current will not flow.

If you unplug the power supply, the solenoid drops out because the current stops flowing through the coil. However, the coil has inductance, which has the property of resisting any change in current flow - that is, the power supply will stop producing current, and the coil will start producing current in the same direction, until its magnetic field is totally gone.

Think of the stripe as an arrow showing you which way current is allowed to flow through it, and imagine you just unplugged the power supply. Understanding that current will no longer go through the power supply, you should be able to see that it will now flow out of the coil and through the diode.

If that diode were not installed, the coil can produce something called inductive kick, which can and will destroy the power supply by pushing voltage higher until it gets current flow - possibly through something that shouldn't be passing current.