If I build roads in a friendly civilization, are they just free, or does that civilization pay for them, and if they do pay for them is it possible to encumber their economy by filling their nation with roads?
There is another similar but broader question here. The answer left unresolved your particular question - what happens to roads you build in other players borders.
Roads inside a civilization's territory are paid for by the owner of the territory.
Roads outside any borders (neutral territory) are paid for the constructor of the road.
So you can theoretically wage economic warfare by building roads in other players land.
Also another nugget - roads that used to be in a civilization's borders (aka when a city is razed) are free - nobody pays for them.
Some empirical work with screenshot from a hot seat game on settler difficulty, so 3 roads = 1 gold.
You pay for roads outside your territory - 6 roads here
Owner of territory pays for roads you build in their territory (view from both sides - 9 roads built by Teal, 3 in Blue, 3 Neutral, 3 in Teal)
And nobody pays for roads that used to be in someone's territory (screwed up the screenshot from the original owner's side, so you'll have to take my word for it)
[Insert missing screenshot]
Also, some quick digging around in the SDK source code. Since my digging was somewhat cursory, there might be some more edge cases around. The relevant code files and functions in the SDK are:
CvTreasury.cpp, which is called in a variety of functions in
CvPlot.cpp to remove and add maintenance cost when plot ownership changes, such as
setOwner() - note that when ownership is taken of a plot (aka plot becomes part of a civilization's territory), the variable tracking the original constructor is set to nobody
setRouteType() - called by
changeBuildProgress() when a road is completed, which also calls
SetPlayerResponsibleForImprovement() if the road is built outside anyone's territory
setPlotCity() - only seems to be used when a city is about to be razed, called by