Capital Gains and year reported

I purchased a stock in 2022 and on December 31, 2022 I had a realized gain showing on my Captial Gains/Losses statement of $8,837.49 for sales in 2022 for this stock.  I still had some shares going into 2023.  On January 6, 2023 I sold the remaining shares of 968 at a price of $32.50 per share to have a realized loss of ($11,962.13).

 

On January 6, 2023 I "repurchased" that same stock for 968 shares at a price of $30.00 per share.  My brokerage firm went back into my 2022 account for this stock and adjusted the gain to $11,192.11, which amounted to adding $2,354.62, which is roughly the difference between the selling price of $32.50 and repurchasing price of $30.00 for a recognized gain of $2,420.00.

 

My question is I was always under the assumption that anything purchased or sold starting January 1 of the new year would be a gain or loss in the new year.  I do not understand why my brokerage firm went back to 2022 to realize the $2,354.62 gain.  Can someone explain if my assumption is correct or did my brokerage firm do the right thing?