Because the code in the first snippet will generate a random number for each subscriber — so subscribers should see different numbers unless the source is published or shared.
The code in the second snippet generates a random number and the source then always emits that particular number.