Some bridges and tunnels are problems, and also some older train sheds at certain passenger stations don't support newer double deck cars; only single-level coaches can be run into those stations.
Bridges can be replaced and upgraded in some cases, and some tunnels can be adjusted, by lowering the floor, or notching the ceiling (if it's concrete not stone) or both. Or in some cases old double-track tunnels have been single-tracked in order to take advantage of higher clearance in the center of an arched roof.
Other times, the route is simply restricted as to what sort of equipment can run through there, or the tunnel can eventually be replaced.
And sometimes mistakes get made; there's a video out there somewhere (unfortunately I can't find it at the moment) of a CN double stack container train that got routed on the wrong track which didn't *quite* have enough clearance under that overpass.... I've also seen some photos of autoracks (loaded with new cars naturally) that similarly got scalped.
An interesting specific example:
Between Sarnia, Ontario and Port Huron, Michigan, the Grand Trunk tunneled under the St. Clair River, which is very wide and deep and a major shipping navigation channel between Lake Huron and Lake Erie. The old tunnel was completed in 1890, and was in use until the mid 1990s when a new replacement tunnel opened which can currently handle anything on the railways. When specialized equipment for the automotive industry (autoracks and high-cube parts boxcars were developed in the 1960s, these would not fit through the tunnel. CN established a car ferry operation to float oversize cars across the river, which was finally made obsolete when the new tunnel opened and the ferries were retired and the dock yard(s) ripped out.
A similar situation existed between Windsor, ON and Detroit, MI where car ferries supplemented the railway tunnel; eventually they increased clearance by lowering the floor in this tunnel, so it can currently handle autoracks and double stacked *international* standard containers, but not double-stacked domestic high-cube containers which are taller and can only be run in single levels.