I know that a set is a collection of distinct objects. Let's say I have a data set $\mathcal{D}=\{x_1,x_2,...,x_n\}$, is it the variables or the objects they are representing that has to be distinct?
For example if $x_1=1$ and $x_2=1$, will both $x_1$ and $x_2$ be in the set?
If $x_1 = 1$ and $x_2 = 1$, then $x_1 = x_2$.
When two things are equal, then any question you can ask will have the same answer for both things.
Often, we conceive this as the strings of symbols "$x_1$" and "$x_2$" being two different names for the same mathematical object. As another example, in integer arithmetic, "$1+2$" and "$3$" are two different names for the same number.
The point of saying a set is a collection of distinct objects is to contrast with another notion called a multiset.
If $\mathcal{B}$ is a multiset, it makes sense to ask "How many times does $z$ appear in $\mathcal{B}$?"
But if $\mathcal{D}$ is a set, the only thing that makes sense to ask is "Does $z$ appear in $\mathcal{D}$?"
Put another way, the sets $\{ 1, 1, 2, 3 \}$ and $\{ 1, 2, 3 \}$ are equal. And they are both equal to the set $\{ 3,1,2,3,2,2,1,3 \}$ as well.