Switzerland is around 40,000 sq km to the US’ 10,000,000 sq km. I don’t think you understand the scale of what electrification of lines in the US would mean.
The relevant metric is population vs rail line length. Switzerland has 8.4M people for 5.7k miles of railway. The US has 335M people for 294k miles of railway. The difference is not too crazy. The total scale is different, but the true problem is probably something between economics and politics. My guesses would be that (1) Swiss railways are pretty much run as a public utility. (2) Swiss railways prioritize on passenger rail, which means more rail near population centers. Diesel is not ideal near population centers. (3) Electrification of rail has been a Swiss priority for a long time, so the marginal cost to add it to new rail installations is low.