In the first case, there is nothing stored in \1 so there shouldn't be any match (and it is an error.) In the latter case, \1 probably
refers to the outer parentheses, but that hasn't taken effect
yet, so there is no match and no error (perhaps it really doesn't make sense but perl tries to interpret it that way...)
If you instead do
print "Match: $1\n" if $test_string =~ /((?:f))\1/;