Swap between Coins, how does the taxing work?

Hi! I dont understand how the taxes are calculated… Whenever I swap for example an altcoin ive made a gain on to LTC just to transfer the LTC to a stablecoin I have to pay taxes for the LTC aswell…

So instead of just paying tax on the realized altcoin gain i also have to pay alot of tax on the swap between LTC to DAI