It is not suggested to change values of "Set Variables" in Loops as per Microsoft document as it gives unexpected result.
Snippet from document:

I have reproduced in My environment. I was also getting same error.

Reason of the error was because value "Value of the day" was fixed.
I have used Compose to get the values of "Value of the day" But in Set Variable connecter values are changing but as you can see below in "Compose" value of "Value of the day" is fixed.



To get the expected result use "current item" instead of Value of day.
int(items('For_each')) is equal to int(variables('utcnow'))
As you can see below:



code view :
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Compose_3": {
"inputs": "@variables('Value of day')",
"runAfter": {
"Set_variable_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Condition": {
"actions": {
"Compose": {
"inputs": "@items('For_each')",
"runAfter": {},
"type": "Compose"
}
},
"else": {
"actions": {
"Compose_2": {
"inputs": "@items('For_each')",
"runAfter": {},
"type": "Compose"
}
}
},
"expression": {
"and": [
{
"equals": [
"@int(items('For_each'))",
"@int(variables('utcnow'))"
]
}
]
},
"runAfter": {
"Compose_3": [
"Succeeded"
]
},
"type": "If"
},
"Set_variable": {
"inputs": {
"name": "Value of day",
"value": "@{items('For_each')}"
},
"runAfter": {},
"type": "SetVariable"
},
"Set_variable_2": {
"inputs": {
"name": "utcnow",
"value": "@{formatDateTime(utcNow(),'dd')}"
},
"runAfter": {
"Set_variable": [
"Succeeded"
]
},
"type": "SetVariable"
}
},
"foreach": "@variables('Set_Period')",
"runAfter": {
"Initialize_variable_2": [
"Succeeded"
]
},
"type": "Foreach"
},
"Initialize_Period_of_time": {
"inputs": {
"variables": [
{
"name": "Set_Period",
"type": "array",
"value": [
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Value of day",
"type": "string"
}
]
},
"runAfter": {
"Initialize_Period_of_time": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_variable_2": {
"inputs": {
"variables": [
{
"name": "utcnow",
"type": "string"
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Month",
"interval": 1
},
"recurrence": {
"frequency": "Month",
"interval": 1
},
"type": "Recurrence"
}
}
},
"parameters": {}
}