There're templates made like {{countryflag|spain}} with a nice table which include [[Image:flag of {{{1}}}.svg]], so it's impossible the bot can detect why the flag is included. Remove te mplates first is a good point.