Ansible resolves variables through a fixed precedence list of 22 levels. Extra variables passed on the command line with -e or --extra-vars sit at the top and cannot be overridden by anything inside the playbook, including set_fact, vars on a task, or a value registered from an earlier task.
The symptom is a set_fact that appears not to take effect. Debugging by printing the variable shows the extra-var value, and nothing in the playbook explains why. It matters most in CI, where a wrapper script may pass -e values nobody reading the playbook is aware of.
Role defaults, in defaults/main.yml, sit at the bottom and are overridden by almost everything, which is what makes them the correct place for values a consumer should be able to change. Role vars/main.yml sits much higher and is nearly as sticky as extra vars, so putting a value there and expecting an inventory variable to win does not work. Inventory group variables lose to host variables, and group_vars/all loses to any more specific group.