In some world, the creatures that came before humans made some huge golems; about 100 meters (a bit under 330ft) tall and eventually disappeared, leaving the golems behind. How would human societies evolve around the fact that those creatures are walking around? Feel free to consider any period of time up to near future with space exploration and stuff.
How would cities and society be built with the thought that sooner or later they will crumble no matter what?
If most people can claim to have "seen one" that's an average of one per lifetime, or an event between once every 45 to 90 years.
That's not very much. California gets on average 15-20 earthquakes of magnitude 4 yearly. Houston gets one bad Hurricane or rain event every 7 years, and that's an event that's 100 miles wide. Both of these kinds of disasters impact whole cities, a Golem would just cut a path through part of the city.
And that's if the sighting actually had the Golem moving through the city. Most sightings would have the Golem passing by a city, unless your cities cover substantially more earth than the country side.
Golem defense would be discussed, but rarely implemented, because one doesn't pay for defenses against the unlikely, unless it's a fear reaction after the event has occurred.
Taking into account different historical periods is a bit tiresome, so I'll just throw my two cents here:
The biggest issue with your golems is that they roam the land endlessy and they have the tendecy to destroy things in their way. Since the golems are probably unstoppable, the best thing your humans can do is to make way. This requires living in wagons, tents, and every other kind of movable home. I'm sure the idea of tent-cities doesn't sound tempting at all, but if a golem is spotted in the distance, it would be rather trivial to "move" the tents out of its way. Or, at least, if a pair of tents gets smashed, it's not a big deal for the society as a whole (rather than having to rebuild a city periodically).
A corollary idea is to make building so unexpensive that wasted homes can be rebuilt easily. Now, I'm not sure if this is someway attainable (especially at lower tech levels). Nowadays we are just starting to have modular buildings, and this could well be a thing in your world.
A more practical solution could be building any important thing beneath the earth, in tunnels, and make use of natural caves or such. From your question, I don't imagine your golems punching the sides of a mountain, or stomping their feet to make the ground quake on purpose.
To be fair, it would probably be difficult to have nice, comfortable tunnel cities (because humans aren't exactly equipped to live underground). Also, a random golem walking would still pose serious threats to most tunnels, so your humans would need to get good at architecture and geology fast.
A safer solution could be provided by natural caves; those have usually entrances small enough that your golems couldn't be able sneak in - unless, again, they don't usually raze mountains to the ground when they need to pass through. Caves are rarely large or frequent enough to sustain a growing population tho.
They don't care much if something on their way. If there's a city - they'll walk over it, smashing whatever in it's path. If there is a wall about as tall as the golem itself - it gets one or two punches until it breaks. if nothing happened - golem just tries to climb over it or walk around if it looks faster than climbing.
So, pretty much, cities could be built over elevated areas and golems would walk around (unless they are specifically programmed to walk OVER the city. Are they such jerks?). The only issue here is the golem height - building an artificial plateau more than 100 meters high seems troublesome, but you should consider this in case you wish to make them smaller.
One thing you should consider is that, at any given moment in history, humanity WILL try to find a way to stop golems. They don't need to be destroyed, just stopped or re-routed. You mentioned that golems can climb pits, ad example, but what would happen if humans were to shower molten metal over the golem? I assume those golems have some sort of junctures; human would just need to block those. Assuming the constructs are not invulnerable or infinitely strong for plot reasons, sooner or later there should be a way to block them.
And lastly, my favourite:
Build giant puppet-golems on wheels:
Golems will change angle when seeing one of their kind, so maybe building a replica golem with wood and hay would trigger the high-five mechanism. If that's so, you can build a set of fake golems on wheels, much like siege engines, to redirect incoming golems out of your city. True enough, this would look so funny that it would make a great paradoxical fantasy, but it's your call.
While others are focused on surviving the roaming golems, I'm trying to imagine ways they could be exploited for profit. Once humans figured out the limit of people the golems will allow on them, they could be used for transportation. Sure, it looks like humans can't control the golem's direction, but a "driver" could send out messages to people where its heading.
Bear in mind this transformation is inferior to most ride-able animals, but its a luxury I could imagine people would go for.
Speaking of "drivers", setting up the equivalent of a lighthouse on the giants would be useful for travelers. This might be a dude with a churchbell on the giants dome or an actual lighthouse based on the era. With these convenient walking signposts, caravans could follow golems and trade with people who saw the signals.
For bonus points, imagine having the wagon tethered to the golem's waist and getting pulled along that way.
And just because no setting is complete without some darkness, some societies could use golems to execute criminals. Tie them where the golem will walk and let the seemingly divine being crush them into pepperoni with their unceasing feet. Oh, and people altering themselves to look like the golems might be a facet of some religions.
edit- Birds would love these things! Same with whatever plants that could live on them. I can't imagine a better system for spreading your seeds.
Couple of points for anti-golem city defence:
Also - aside from building cheaper building, your inhabitants may just not care. There's already enough natural disasters, wars, acts of god and shoddy contractors that can destroy buildings/cities that the Golems may just be classed as natural disasters - easily seen ones at that.
They have plenty of warning, so they'll just evacuate ahead and then rebuild after it's passed. Probably do less damage than an earthquake anyway.
Your society could exist in a nomadic Bedouin caravan existence. They're constantly on the move so as to avoid being trampled by the golems. Depending on what area they live in this could actually be a good thing because basically they would be a culture that lives off the land. Portable homes like Teepees would be the way to go.
Another idea is that your people live high up in the mountains. The golems would be too heavy to come up after them. At the bases of many mountain ridges are the smashed corpses of golems who did not survive their ascent. There are probably a lot of them trapped under rockslides, mudslides and avalanches too. Golems aren't too bright.
However, if your society is modern, just bomb 'em. I would imagine a nice barrage of artillery shelling would do the trick. Golems might be powerful, but they're just stone. Bunker Busters are pretty powerful too. A modern society could handle the problem I think.
My first thought was floating cities. The golems would walk underneath you and cause no issues.
On land you'd build underground so the golems go over you.
Same thing with pits - jumps over it or walks around(or jumps down and climbs out on the other side)
In the beginning people would just move away, let the golem destroy whatever was not moveable in time, move in and rebuild. Sort of like a minor, predictable quake. I'd expect that golemancy would be a thing, and all religions would include golems somehow. Maybe sacrifice by golem stomping?
Then, some areas would be located where the golems don't go due to geographical features - hills too steep, or canyons. And what about swamps, or large fires?
Finally, people would start building artificial canyons so that golems walk around their cities.
(Also, no doubt, war campaigns would rely on disruption by golem to some extent).
With 1700-1800 technology, you could build an enclosed area between two large enough pits (once you discovered the appropriate size for such pits) so that golems start walking round and round the same areas.
Eventually I expect they'd find out some way of harnessing golem power... maybe using gigantic treadmills and cinema screens to make the golems believe they're moving.
Gildartz is an over-powered character in the Anime - Fairy Tail. He is kind of similar to the Golems. He is not huge or anything but his magic is such that, he disintegrates anything he touches. He goes on multi-year quests, so he only returns to the city once in a few years (similar frequency as Golems?).
He is a bit scatterbrained though (most of the time), and a drunkard, so he doesn't follow the road. He simply walks in a straight line from the city gates to the Fairy Tail guild. In the process, he destroys any buildings that happen to be in his way (not intentionally, he just walks without seeing). Every time Gildartz returns to the city, the city gets half destroyed.
After this happened a few times, the city administration decided that since they could not stop Gildartz (because he is OP), they would change the city itself. So, they setup an alarm system which would alert everyone when Gildartz returns from one his quests. They also setup a city-wide magic-array, that would re-arrange the city in such way that there would be a straight path from the main city gates to the Fairy Tail guild. And the city would stay that way for the few days that Gildartz remained in the city. They would revert back to old structure once he left.
Maybe the same can be done for the Golems.
I'm not sure it's strictly necessary, but this would be a good excuse for building a world with advanced, modern civilizations that are completely mobile. In our world, we associate a nomadic lifestyle with traditional, low-tech lifestyles, and smaller groups. But could you have a million plus people somehow wandering around the world together, while enjoying a high tech lifestyle? How do you maintain that population density without skyscrapers? It's worth thinking about.
Given that the existence of the golems places restrictions on city-building, the pace of scientific development would be slower. In general, such developments happen when people have time outside basic survival to play around with new ideas, and those places would be fewer in your world world. I'm assuming that all of the ideas in the other answers for fixed-location cities work satisfactorily, but they consume time and resources, and in many cases cannot be done everywhere.
A significant feature of the real world that enabled both social and scientific advancement was agriculture, which allowed us to stop being nomads and have a bit of free time to discover electricity. This is made worse by the fact that the better agricultural areas - large flat ones - are indefensible against the golems. I'd expect the rate of scientific and technological advancement to be significantly lower than the real world - another few thousand years between recorded history and the renaissance - and that will have several flow-on effects.
Once you get to the industrial revolution, you have even more reason to invest in large areas of land in a single place, so I'd also expect the explosive rate of technology we had then to be much slower, due to the scarcity of places that will survive golems.
The overall effect I think you'll see will be to have a few relatively isolated silos of science and culture in the few places that are able to build and maintain a fixed city, with the majority of other people living low-tech, nomadic lifestyles. It would not be unusual for the cities to have technology the nomads do not - they may have crossbows where the nomads on have spear-throwers, for example - but the cities would have limited means of sharing technology with other far-away cities, other than dedicated pilgrimages of scholars. The nomads themselves will use whatever technology they can find, but will probably not have the means to produce it themselves or improve on it further.
The cities will have to be largely independent - they will trade (and fight) with the nomads, but cannot rely on them as a source of peasant labour, because they won't stay long. There is unlikely to be a central power in any place for long - one city may conquer or ally with another, but unless they are very close they will become separate again over time.
Supply lines to support wars in far-off places will be difficult, because nomads would be happy to plunder easy supplies, and there will not be as much in the way of local villages that can be raided for "self-supporting" armies, so there would be no Alexanders or Khans in this world. Large standing armies would therefore not be very useful, so it is very likely that this is not Sparta.
It is highly likely that the cities and nomads conflict just as easily as trade - the cities will need large arable areas that are not easily defended (I'm assuming these areas are relatively unaffected by golems - after a golem passes, they can simply re-cultivate the area, and they will only suffer a temporary loss), and the nomads can (and probably will) raid them often. The nomads will not have a strong incentive to take the fight to the cities, since they are easy to defend, and the cities will equally not wish to pursue the nomads, since the nomads can keep running as far as they want, but the city's army is limited in its range. This means that despite the raids, war is unlikely, and trade will continue.
The cities, being so isolated, will develop fairly different cultures from one another, with strong differences in dialect and language too. The nomads are likely to be more homogenous within a large geographical area, which is likely to lead to a nomadic language being the language of trade. The nomads will tend to prefer oral histories, have stable traditions, and long memories.