It is not supported to definite variables with the same name in same stage but different tasks. The document has mentioned the scopes of variables.
Custom variables can be defined at various scopes.
Share values across all of the definitions in a project by using
variable groups. Choose a variable group when you need to use the same
values across all the definitions, stages, and tasks in a project, and
you want to be able to change the values in a single place. You define
and manage variable groups in the Library tab.
Share values across all of the stages by using release pipeline
variables. Choose a release pipeline variable when you need to use the
same value across all the stages and tasks in the release pipeline,
and you want to be able to change the value in a single place. You
define and manage these variables in the Variables tab in a release
pipeline. In the Pipeline Variables page, open the Scope drop-down
list and select "Release". By default, when you add a variable, it is
set to Release scope.
Share values across all of the tasks within one specific stage by
using stage variables. Use a stage-level variable for values that vary
from stage to stage (and are the same for all the tasks in an stage).
You define and manage these variables in the Variables tab of a
release pipeline. In the Pipeline Variables page, open the Scope
drop-down list and select the required stage. When you add a variable,
set the Scope to the appropriate environment.
This maybe a workaroud to change the value of variable after one task.

Please refer to this issue: How to modify Azure DevOps release definition variable from a release task?