Yes, retirement plans are marital assets subject to division to the extent they were earned during the marriage. State laws differ on how to determine exactly what “earned during marriage” means so be sure to check with a local expert. In California the presumption is that any pension plans, 401K balances and other retirement accounts are community property and subject to division unless/until proven otherwise. If the retirement plan benefit was earned during marriage it will be divided.
In order to earn pension benefits a worker must be employed and participating in the plan.
In order to participate in a 401K plan the worker must make contributions to the plan by deferring wages from his or her regular paycheck.
Since both examples would require the participant to earn their benefit in one form or another, either time in the pension plan or contributions to the 401K, these earnings are considered community property or martial assets and will typically be divided 50/50 unless their are other extenuating circumstances or the parties agree otherwise.
Be careful though to make sure you are dividing apples with apples as retirement plans are pre-tax money where as other assets may have already been taxed. The difference in value between $100,000 pre-tax and $100,000 after tax could be $20,000 or even $50,000.