You don’t pay tax on purchase. You only pay tax (outside an ISA) on sale, and only on your profits, and you have a £12k allowance.
You won’t lose money if you buy them back again at the same price. It is the equivalent of not having sold them at all, right? And you (rightly) don’t think you’ve lost any money right now, just because they’re red.
For example, you purchase 1 share when it costs £1. 1 year later, the value has dropped to 50p.
Scenario 1: You do nothing and hold for another year.
Scenario 2: You sell your 1 share for 50p and make a tempory loss. You buy back 1 share for 50p the same day. You hold it for another year.
After that additional year the stock price is up to £2. In both scenarios you hold 1 share at this point in time, and your investment is worth £2.
What matters is the price you buy back at: it must be equal to or less than the price you sold at, or you will make a loss. But due to random price volatility, you could get unlucky and buy back at a higher price regardless of if you sell when it is green or red.