Buildifier's reformatting depends in part on the path to the file relative
to the workspace directory. Normally buildifier deduces that path from the
file names given, but the path can be given explicitly with the -path
argument. This is especially useful when reformatting standard input,
or in scripts that reformat a temporary copy of a file.
Indeed without -path, it won't format the files properly. Specify it.
buildifier -h says:
Indeed without -path, it won't format the files properly. Specify it.