In a dissolution of marriage action, all assets that were accumulated during the marriage and all debts that were accumulated during the marriage are put into a spreadsheet. Those assets and debts are divvied up between the parties to achieve an equitable result. What happens to a retirement plan or 401(k) plan, depends upon what other assets or liabilities are distributed and how they're distributed.
Now, if a 401(k) or retirement plan is distributed to in whole or in part to the other spouse, there are legal mechanisms that allocate those funds or those assets to the other party upon the conclusion of the divorce action itself.