Why can't a set have two elements of the same value?
The short, perhaps unsatisfying answer is, because that is how they are defined. The long answer is that, in most cases, that is what is useful.
For other cases, there is also a theory built around multisets, which are like sets except they allow multiplicity.
I'd say that $B$ is valid and equal to $\{1, 2, 3, 4\}$.
The notation $B = \{1, 1, 2, 3, 4\}$ gives $B$ by listing its elements:
$1 \in B$
$1 \in B$
$2 \in B$
$3 \in B$
$4 \in B$
Clearly saying twice that $1 \in B$ is harmless.
This is the axiom of extensionality: two sets are equal iff they have the same elements.
Do not think of 1 and 1 as "two elements of the same value". They are the same element really. And an element is either a member of a set or it is not.