I'm thinking of a lot of European cities, but some American cities (thinking rowhouses) and Asian cities (shophouses) as well.
Also, were the structures built by a single developer at one time, or by individual developers to match what was already there?
There has never been a shift from one to the other. Keep in mind, standalone building may range from tents to single-detached bungalow houses, to temples, and connected structures exist in the ancient Old City of Jerusalem, Dickensian London, and the contemporary condominiums of Vancouver.
Nevertheless, the greatest determinants of whether a structure is attatched or detached (or even semi-detached) tend to be the proposed use and the cost of land.