If I want to change only two tyres and keep the other two, should I install the new ones in the front or rear?
I can imagine only a couple of reasons why you would end up with a pair of half-worn tyres and another pair of completely worn ones.
In all likelihood, you did not bother to rotate them as instructed in the car manual. And now you want to compound the problem by keeping the old, half-worn ones.
The other reason might be that you managed to puncture two tyres at the same time, which is quite a rare thing to happen.
If you ever have to replace just a pair, the rule of thumb is to install the new tyres at the rear because losing grip at the rear is deadly dangerous for the average driver.
But if you can, replace the whole set and remember to rotate the tyres regularly.