According to perlvar:
$. is reset when the filehandle is closed, but not when an open filehandle is reopened without an intervening close().
Because "<>" never does an explicit close, line numbers increase across ARGV files (but see examples in eof).
(second emphasis added)
When you use -p, @ARGV is set to the list of files you passed on the command line. Since $. is not reset when you go to the next file, it will only equal 1 for the first file. You can see this by simply printing $.:
$ echo foo > foo
$ echo bar > bar
$ perl -pe 'print "$. "' *
1 bar
2 foo
(with -p lines are printed automatically, so in the above example, the content of each line is printed next to the value of $.)
If you close the special filehandle ARGV when you move to the next file as mpapec suggests, $. will behave as you expect:
$ perl -pe 'print "$. "; close ARGV if eof' *
1 bar
1 foo
See the documentation for eof for more details and a couple of good examples.