Get your taxes done using TurboTax

In short, yes, you have to file an amended return for 2021 to correct an error, including reporting a gain when there was a non-taxable distribution.

And no, we can't just adjust 2023 to make up for a mistake in 2021. If we could, rich people with expensive accountants would do this all day long to the detriment of tax collection :-). Of course, instead they're busy doing other things....

Each tax year stands on its own, with allowed carryovers being very carefully defined and limited.