When each world is generated, it will randomly assign a seed to that world, however, it is possible to manually assign a seed to a world by typing in a series of numbers or sometimes words.
How Minecraft does this is through is a system referred to as seeds. Minecraft is known for generating infinite worlds with infinite possibilities of how these worlds actually look.