The second <p> is not inside of the first. The first <p> closes when the second <p> is encountered.
The syntax is invalid, but that's because the final </p> has no opening <p> that it can close.