Because aux is the required contraction of à + les.
So:
à + les = aux
That means:
aux haricots = to the beans / over beans, depending on context
After préférer, it gives the second item in the comparison.
Because deux by itself usually just means the number two. Les deux points to two specific things already mentioned and means both or the two.
So:
deux = two
les deux = both / the two ones we are talking about
Because aimer can mean both to like and to love, depending on context. With food, hobbies, and general preferences, it usually means to like.
So in this sentence:
ma sœur aime les deux
most naturally means
my sister likes both