It's impossible to keep a 401K separate - marriage and divorce WILL result in a QDRO division. However, an IRA in which no further contributions are put in will kept separate (basically like a regular asset in a community-property state), so the thing to do before marriage is to transfer the pre-marriage IRAs to a completely different custodian, and don't add any contributions to it. A pension (for those who still get that, LOL) will be split up similar to a 401K. In a community-property state, an asset that was acquired before marriage - so long as it isn't "intermingled" with community (i.e., post-marriage) property - remains separate. The beneficiary status of an irrevocable trust is also separate (so long as it was competently drafted).
Of course, worrying about assets is only one issue. The other issue is alimony so as to keep the ex-missus in the style to which she is accustomed, and child-support, which often has an alimony-esque component.
As for the whole marriage thing, the only way to properly do it is to only do it after early retiring (which also allows for GeoMaxxing
), and in a community property state, where assets are cordoned off. If still working, there is the risk of having virtually all of one's income hoovered up by the ex and the kids - like a colleague of mine in the late '80s that was left with $600/mo of his ~$5000/mo nominal income.
It was depressing as h3ll to see the sorry-looking bologna sandwiches he would brown-bag.