Reusing a label (variable name) is legal in JavaScript – and many other languages. What happens is that the later uses “hide” the earlier ones. Sometimes this is intentional, other times it is not.
I think what happens when you do something like this:
var sprite = createSprite(100, 100);
var sprite = createSprite(200, 200);
Is that the sprite objects are stored in an array or list (to facilitate processing by drawSprites()
) and a reference to the sprite object is returned and stored in a variable called sprite
– since the second call to createSprite()
also stores the reference in a new variable called sprite
which replaces the first reference since they have the same name.
The result is that the list of sprites has two sprites in it, but we only know how to find and refer to the last one. So drawSprites()
still draws both sprites, but we only have a. way to refer to the last one.
It’s kind of like having one bank account, and then setting up a new one – but instead of adding a new entry in your address book of the second bank account you replace the information in your “bank account” entry with the details of your second account. You still have both bank accounts, but you only know how to get to the second one. The first one is effectively lost to you – at least until they send you a statement 
This is why I lean heavily on my students to always give their sprites meaningful names. To the point that I add it to the description of my rubrics.