Prehistory and origin of Stockholm
According to the Chronicle of Eric, written in the 1320s, Stockholm was founded by Birger Jarl around 1250 as a lock to the Lake Mälaren region ("laas fore then sio", "lock before that lake") in order to prevent pirates from reaching the seven cities and nineteen parishes around it. Another medieval source ("Visbyannalerna"), however, claims the city was founded in 1187 following a pagan pillaged the city of Sigtuna, and as there was an "Earl" named Birger around at that time too, the disputed origin of the city are likely to remain obscure and some historians choose a diplomatic interpretation saying there was some sort of fortification around by the mouth of lake Mälaren when the city was founded during the second half of the 13th century. As Snorri mentions no city in his account but some sort of fortification called a "kastali" (in various manuscripts curiously said to be located east and west of "Stocksund"), it has generally been assumed this fortification eventually developed into the castle Tre Kronor located where still is the Stockholm Palace.
Architecture in Stockholm
The 14th century saw King Magnus's disputes with the Danish provinces of Skåne and Blekinge leading to attacks on Swedish cities, including Stockholm. This led to the construction of a fortress in Gamla stan, Stockholm's Old Town. This was period in which Stockholm, as it had only recently been referred to, moved between the bridges surrounding Gamla stan's structure for security. The city structures were built of wood except for the Cathedral Storkyrkan and a tower called "Three Crowns" which were more monumental. 
Stockholm's development was also especially influenced by Germany because of the great volume of trade occurring between the nations at the time through the nearby waterways. The North German architecture is most prominent in Gamla stan.
The 15th century saw the Battle of Brunkeberg break out in the middle of downtown Stockholm. King Gustav Vasa rose to power as a result of the dispute and declared the city an independent monarchy. This maneuver is credited with lifting Stockholm's development to those of other major European cities. The city was rebuilt and developed further in the next centuries. The city expanded greatly. Infrastructure increased exponentially for transport and other public services.
Likewise, royal wealth had increased dramatically and large palaces were constructed, like the Royal Palace.