This phenomenon is because larger ships are more efficient, and ocean shipping is a super competitive, low-margin business (during normal times) like the airline industry, so in order to eek out a tiny profit, ocean lines consolidate and build bigger and bigger ships, which further drops prices. These ships can only actually go to a handful of megaports around the world, though.
Another factor is the infrastructure that exists at the ports - you need to do something with the cargo once it gets on shore. LA/Long Beach has invested in big, efficient terminals for trucks and trains to get loaded quickly and move cargo out of the port in big volumes.
Source: I used to work at Flexport on ocean shipping, so I have a general understanding of the industry