You must explore and buy what you find in different locations on the map. However, you will get everything for free in the cracked version of Terraria.