Let me provide an example. You put $10,000 in a regular 401k and it appreciates to $15,000 before you withdraw it. Your W2 income is reduced by $10,000 when you contribute and you pay ordinary income tax on $15,000 when you withdraw.
You put $10,000 into a taxable brokerage account that appreciates to $15,000. You pay ordinary income tax on the $10,000 when it is part of your W2 salary. When you sell the stock/mutual fund in the brokerage account, you pay capital gains tax on $5,000
So in a retirement account, you have paid ordinary income tax on $15,000. If a taxable brokerage account, you have paid ordinary income tax on $10,000 and capital gains tax on $5,000. The statement "Not paying capital gains is really the main advantage of retirement accounts" is not accurate.
The advantage of the retirement account (pre-tax) is that you get to defer more income and earn the appreciation on more money over time and then presumably pay tax on income in your retirement years when your total taxable income is lower. You also presumably get a company match, in the case of a 401k.