Trying to understand the Python for-loop, I thought this would give the result {1}
for one iteration, or just get stuck in an infinite loop, depending on if it does
I believe this has got something to do with the actual implementation of sets in python. Sets use hash tables for storing their items and so iterating over a set means iterating over the rows of its hash table.
As you iterate and add items to your set, new hashes are being created and appended to the hash table until you reach number 16. At this point, the next number is actually added to the beginning of the hash table and not to the end. And since you already iterated over the first row of the table, the iteration loop ends.
My answer is based on this one of a similar question, it actually shows this exact same example. I really recommend reading it for more detail.