Why are there four? I would guess it was fixed after the egocentric/"relative" directions (left, right, front, back). Or was it because human used to consider the ground as flat and 2-dimensional?
How are they defined? Wikipedia says their English names have origins in Proto-Germanic words related to sunrise, so probably East is defined as the direction where sun rises. But how exact is such directions? As we know, in the northern hemisphere the sun rises precisely due east only on the equinox. Why was East not picked as a direction somewhat eastnorth or eastsouth? Or did cardinal directions origined in a civilization living near the equator? Did the Inuit have a more southern East?
Are they "natural concepts"? I remember I was taught the directions at school when I was a little kid. Could a person develop the concept of cardinal directions without influence from teacher/parents? How important are the directions for hunting/gathering/agriculture in a prehistoric environment? Do animals have concepts of directions?
Did the early civilizations have different definitions for the directions? How do they influence each other? If civ A traded with civ B and noticed they used a "somewhat rotated map", would any of the civs change their direction system?
The origin is astronomical. North is the direction to the North Pole of the celestial sphere. (To the point about which the sky performs its daily rotation as seen from the Northern hemisphere). The opposite direction to this is called South. South is also the direction to the Sun in the middle of its daily way over the sky. These directions are of fundamental importance.
East-West are perpendicular directions (in the horizontal plane). East to the side where the Sun rises, and West where it sets. But the Sun rarely rises or sets exactly in the East/West.
Why 4? Because the horizontal plane is 2-dimensional. So you need two axes to describe the points and directions in this plane. But it is convenient to have different names for the "positive" and "negative" directions of these axes, therefore we have 4. (We are talking of the times very long before negative numbers were introduced, possibly before ANY numbers were introduced. So the subject does not belong to history in the technical sense, but rather to pre-history).
There are natural concepts, even long before civilizations. The period in time when they were really needed was the introduction of agriculture. (Long before "civilization" which is usually associated with writing, states, etc.)
To do agriculture you need the notions of the year and seasons of the year, when they start and end etc. All these notions are of astronomical nature, and you can clearly establish them (and most importantly PREDICT them) ONLY by observing the sky.
When you just begin observing the sky, the first thing that you notice is that the sky as a whole rotates about certain point with period of revolution which we call day-and-night (or simply "day" in English, which is highly confusing, see the below).
This point in the sky is seen in the North direction. The South direction is even easier to observe: it is where the Sun is in the middle of the day. These directions never change. The directions to the points where the Sun raises and sets do change during the year, but to describe them one needs some fixed points of reference, and these are East and West, so that EW-axis is perpendicular to the NS axis.
Reference. The oldest surviving treatise on agriculture, Hesiodes, Days and Works. (Translated from the ancient Greek to all modern languages, I suppose, and free of copyright:-)
Remark. Some languages have a single word for the day-and-night period. The technical name in English is nychthemeron (how many English-speaking people have ever heard this?) If your native language does not have this word, see Wikipedia about it. This word is clearly Greek, not native to English or German languages. Wikipedia gives a very interesting list of languages which have such a word as a native word. I always wondered what this list says about history or prehistory of various languages and peoples and astronomy etc.:-)