It has everything to do with names. Among the things that programmers sometimes believe about names, as in this case, is that when you stick apostrophes around them they are always a valid SQL string literal.
Inexperienced programmers naively believe that about all string input, so the fact they believe it about names isn't particularly interesting.