It turns out that I create a tag or a task or a quiz, and it effectively adds them.
But when I delete that tag or that task, in the database it is not deleted, that tag still exists in the database.
And as I am doing some queries to the DB I will always appear those tags, since I would not be eliminating from the DB.
General developer forum
Help, moodle 3.3 NOT DELETING FROM THE DATABASE