First off, you must synchronize them somehow. Carts picking different amount of items will have different momentum and speed, so they'll eventually meet up unless you re-adjust their gap. This is easiest done with a PEZ dispenser - a device for storing minecarts and deploying them on demand.
This is a typical design utilizing a fence gate. It's very simple but the gate must receive a very short pulse not to dispense multiple minecarts. (the attached Etho clock is good for such a source)
The design utilizing a slab and a sticky piston to push minecarts onto the rail is more tolerant to different clock outputs (here - powered from a fader clock) though slightly more complex and less compact. You may also want to cover the minecart tower (say, with glass) to prevent accidentally bumping into it.
They are also a reasonable way to store the minecarts when the farm is not in use - simply disable the clock and wait for all the minecarts to stack up.
This solves your problem if you're afking near your farm and dutifully shut it down before leaving. But if you leave your farm running and then leave, you're inviting trouble - by unloading it partially.
As long as the entire 'railway system' is contained within a single chunk (F3+G to display chunk borders) it's not a problem - cart positions get saved, their momentum is slightly affected, but the PEZ dispenser will even everything out as long as you don't skimp on powered rails and don't get your carts near to stop in between them (unloading slightly decreases the momentum).
The real trouble start if the rail crosses chunk border, and you go to a location where some of the chunks in the farm are loaded as entity-processing, and some (on the very border of the loaded area) are lazy chunks - in which all entities (including minecarts) freeze. In this case all carts in entity-processing area will cross over into the lazy chunk and clump up into one massive pile.
There are several ways around that, but none "bullet-proof". The easiest is just discipline. Shut the farm down properly before leaving, let the carts pile up in the PEZ dispenser awaiting next start of the farm. Another is building the farm in spawn chunks. They aren't as reliably "always loaded" as in the times of old, but you'd need a pretty bad set of circumstances to make some of them unload. As you mentioned elsewhere though, you're building a gold farm, and that implies the Nether. No spawn chunks there.
Last but not least - build a permaloader. It's a device that keeps an area of 3x3 chunks (with the chunk with it in the middle) permanently loaded as entity-processing.
This is a very simple, cheap and easy to build permaloader - you build two well-linked portals facing the same axis (either both X or both Z), and attach the rail structures to both, on respectively opposite sides (say, rails go on +X side of the portal in overworld, -X in the Nether.) Make sure to pass through the portal at least once.
Open the fencegate and start sending minecarts into the Nether. After placing 4th minecart, first minecart from the Nether should have returned and your permaloader is active - the area of 3x3 chunks around it is loaded for as long as the server is running (if the server restarts, you must revisit the area to load it and let it start going again.) Close the fencegate to stop it.
You'll be able to find many other designs - more lag-friendly, reliable, compact, and so on - I'm posting this one because it's exceptionally simple and this is not a question about permaloaders.