This is covered by section 3 of the Terms of Service (linked to from every page as “legal”):
You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license. […] Subscriber warrants, represents and agrees Subscriber has the right to grant Stack Exchange and the Network the rights set forth above. Subscriber represents, warrants and agrees that it will not contribute any Subscriber Content that (a) infringes, violates or otherwise interferes with any copyright or trademark of another party, […] (c) infringes any intellectual property right of another […]
The copyright notice by itself is not a problem (lots of open source contains them too, since all code is actually copyrighted). What is problematic is that it seems the poster does not actually have the license to release the code under CC-BY-SA (or release it at all).
I think flagging the question was the right thing to do and that at least the questionable part of the code should be removed. You might also consider editing the question to remove the problematic code.
But I don't think downvote is warranted, since this issue doesn't fall under what downvotes on questions are for (“This question does not show any research effort; it is unclear or not useful”).