A NAND gate functions internally as an AND gate followed by an inverter (indicated by the little circle at the right end). In your top example, you have a NAND gate followed by a second inverter, which simply turns the combination of the two gates into an AND gate -- not an OR gate at all.
The main thing to remember about a NAND gate, is if any input is 0, then the output is 1. (And the output is 0 only if both inputs are 1.)
So in the top example, the output of the NAND is 0 only if both inputs are 1, so the output of the explicit inverter is 1 only if both inputs of the NAND are 1 -- exactly as an AND gate should work.
In the bottom circuit, both inputs are inverted before being presented to the NAND gate. So now the rule becomes, if any input to the inverters is 1, then the output of the NAND gate is 1, and the output is 0 only if both inputs are 0. Gee, that's the definition of an OR gate.
If you haven't done so already, I would make up truth tables for a NAND gate by itself, and then two additional tables for the two circuits.