The second p isn’t :not(.classy) so it isn’t color: red. This means it still has its default colour, which is color: inherit.
The body element is :not(p) so it is color: green.
The second p therefore inherits the green colour from the body element.
The developer tools in your browser would have told you this:
