Capital gains are the money you earn from the sale of an asset minus the original cost and any fees. The government always expects you to pay taxes on capital gains, and there is no way to completely avoid them. One option is to delay the payment of those taxes until a later date.
Depending on the asset, you may have several ways to avoid capital gains taxes. Investments in real estate, for instance, have several options.