For US railroads, railroad cars may seem to be fungible, but someone owns each one and there's a settlements system running behind the scenes. The Association of American Railroads, via their Railinc subsidiary, is behind that, and all railroads that interchange traffic are members. There are standard rates.
Apparently, it doesn't. I would have thought at least some shipping lines would have gotten together to allow for offsets and settlements and all that to ease logistics. Maybe the lines don't want to coordinate or enjoy the semi-lockin that returning a container to the line's yard means it's most convenient to pick up an outgoing container from that yard, or don't trust their inventory with each other.
How does that work for containers?