The mutation is random but only things which are either neutral or beneficial for the current environment persist as generations come and go. If you insist on comparing Evolution to RNG, imagine it's an image board where post numbers are completely random and the probability of different number sets can be influenced by whether or not the posts get deleted. Then imagine most posts without at least one set of dubs get deleted while most posts with at least one set get saved. Eventually, given enough iterations you will have post numbers filled entirely with dubs, some with trips, very few with quads. Keep on going and eventually most posts will be entirely repeating numbers.