Because backslash escape sequences are not processed on single-quoted strings. So, "\n"this is a newline character (this is one character), but '\n'is literally a backslash followed by an "n" (so there are two characters). You can see this by querying each line of individual characters:
irb(main):001:0> "\n".chars
irb(main):002:0> '\n'.chars
.. or just by printing them:
irb(main):001:0> puts "a\nb"
a
b
irb(main):002:0> puts 'a\nb'
a\nb
source
share