Unrealized gains and losses from trading securities are recognized in Income Statement. So if Stock A goes up, the gain is taxable in the current period. This means you pay taxes for a stock appreciation without having sold the stock.

After that, in period 2, you sell the stock with gains, the selling of the stock automatically pays taxes. Therefore, you pay taxes twice, for the unrealized and for the realized.

What am I missing in the reasoning because that can’t be right.

You account the gain over the last price updated, not from the initial one.

As you said, suppose you bought Stock A for 100 at the beginning of the month. At the end of the month it went to 120. So unrealized gain of 20 goes to IS and you paid taxes for 6 (30% tax rate). At the end of the 2nd month the stock went to 150 and you sold it. The realized gain is 30, not 50. So you pay taxes for 9.

Total gain is 50, so total taxes over 2 months are 15 (9 + 6).