ESV Acts 2:
17 And in the last days it shall be, God declares, that I will pour out my Spirit on all flesh, and your sons and your daughters shall prophesy.
Did God pour out his Spirit on horses, snails, and such in the days of Acts? No. They had whatever spirit that they had before.
This is hyperbole. NIV:
17“ ‘In the last days, God says,
I will pour out my Spirit on all people.
Your sons and daughters will prophesy,
your young men will see visions,
your old men will dream dreams.
Let's restrict the translation to "people" instead of "flesh".
Now the question became
Does "all people" in John 17:2 mean the same as "all people" in Acts 2:17?
In Acts 2, they were living in the last days but not every young man was seeing visions.
Even with this restriction, the phrase "all people" is still a hyperbole.
What does "all people" mean?
To me, it means certain Jewish and Gentile people.
On the other hand,
2 For you granted him authority over all people that he might give eternal life to all those you have given him.
Here it literally means all people, Jews and Gentiles.
Do these contexts alter its meaning, or, does it retain the same meaning in both of them?
The contexts alter the meanings. Act 2 is hyperbole while John 17 is literal. However, both emphasize Jews and Gentiles.