It looks like elastic-package build uses files from the build directory when building packages. So a file removed from a package can be still included if the package is built from a working copy with a dirty build directory.
elastic-package should use clean directories when building packages, either by removing files from reused directories, or by using temporary directories for each build.
This is not an issue in CI because packages are always built with clean directories, but is an issue in local environments, and can be an issue with #1831, depending on how it is done.
The workaround when this causes issues is to remove the build directory.