That's true even if you find code on GitHub explicitly labeled as MIT, CC or Apache.
If you're worried about using code from stack-overflow, use it as inspiration only and write your own code. Or conduct a short search first to see if it WAS copied from another code repository.
There's a big difference between a git contributor explicitly saying their code is a subject to a certain license and SO magically declaring it to be so for all code on their website just because it happens to be in their ToS. I think a better system would be to ask people providing code snippets to specify what license it's subject to.
If you're worried about using code from stack-overflow, use it as inspiration only and write your own code. Or conduct a short search first to see if it WAS copied from another code repository.