The BBC has overpaid some staff by a total of £4million over the last four years, figures show.