Along with the steep gradients, you have to remember there's far more passenger services on the lines, so pathing constraints force freight services to be shorter (you can't have them accelerating that much slower than passenger services, or they start taking up a disproportionate amount of capacity on the line).
Was that itself a response to the exactly-256 problem, "plus a margin of safety"?
Here's Union Pacific's longest container train. 295 freight cars, 9 locomotives. Four axles per car. So that's over 1180 axles. A more typical US train is 100 cars and a few locomotives; over 400 axles isn't uncommon. 256 would be an inadequate axle limit in the US.
(There are longer trains in Australia, but they're usually coal or mineral hauls on dedicated track in flat country. This was a run from Los Angeles to Texas on mainline track.)
FWIW, a lot of freight wagons around Europe are on bogies (with two axles per bogie) where they would be two-axle wagons in the US; I presume a lot of this is down to comparatively higher speeds of freight in Europe as a result of pathing around passenger services. Plenty of freight around Europe runs at up to 160km/h (~100mph), and that sort of speed is fast for a passenger service in the US. Obviously, this doubles the number of axles per wagon (though decreasing axle weight and hence track loading), further shortening the length of a 256 axle train.
It would appear the maximum length of a train in Switzerland is 1500 meters which would push it well above 256 axles.
At the same time, that was a run through the Gotthard Base Tunnel, and running onto similarly modernised infrastructure, and hence less likely to have 40 year old axle counters in use.
It's not, but considering the context going above would mean going through the limit which would be dangerous, during exit the counter would mark a railroad section as unoccupied before underflowing back to occupied. It might also have interesting failure modes during entry.