Purpose of using diode with solar panel
Almost all voltage regulators do have a path backwards from output back into its input because they are not designed to handle blocking reverse current. So your battery would drain back into the solar panel when there is insufficient light falling on the panel.

For example, here's the internal circuit of an LM338 in your first schematic:



(From here)

While there is a path from the output of the regulator back into the input through diodes D2 and D3, it is through high value resistors. Your biggest problem is that you'll be feeding battery voltage back through R22 160 Ohms into the base of Q26 into its collector and out to your solar panel without the blocking diode. And there are other paths like that through other parts of that circuit.

So besides reversed panel connections like @analogsystemsrf pointed out, it prevents your battery from discharging back through your regulator back into your solar panel.

However, in your second circuit, the diode is redundant because the battery already has a series diode. But the diode at the solar panel can serve to prevent damage from reverse connections.