Those were probably builds that were run before you installed
git plugin 4.5.0. The git tag action was removed by default from Jenkins jobs created with git plugin 4.5.0 and later. Refer to the git plugin documentation for the explanation
why the git tag action is not useful in almost all cases with Jenkins.
As a quick test, you can enable the "Add git tag actions to jobs" checkbox in the Jenkins global configuration and run your job again. That should assign the GitTagAction to the new build.
I believe "it" in that groovy loop is used to represent each of the builds in the job, one at a time, while the each loop is iterating over each of the builds.
job.builds.findAll{ it.result.toString()=='SUCCESS' && it.badgeActions }.collect{ it.displayName[1..-1] }
Mark Waite