Let's say I bought a 100-ounce gold bar in 1965, when gold was $35/oz, for a total price of $3500. Let's say I sold it today at $4700/oz, for a total price of $470,000. That gives me a gain of $466,500.

And let's say that I regret it. I decide that I really want to hold some gold, so I take the $470,000 and buy another 100-ounce gold bar.

The situation was that I had a gold bar worth $470,000 with a taxable basis of $3500. Now the situation is that I have a gold bar worth $470,000 with a taxable basis of $470,000, and I owe the IRS taxes on $466,500 of capital gains.

TL;DR: Selling and re-buying the same asset gives you the accumulated gains, and resets the price basis.