It’s always better to replace two tires rather than one so that the tread can wear off evenly. Those new tires should be fitted on the same axle and at the back for best performance and safety.
If you have tires that are at different stages of tread life and one of them reaches their tread wear indicator or your tire was damaged and cannot be repaired. If the other tires are still in good condition, you can still get away with replacing only the one tire.
But this can mess with your car’s electronics like the ABS and traction control getting different signals from the wheels. It can also affect your braking distance, acceleration, and cornering abilities. Replacing only one tire can cause a misalignment in your tires where it gets worn unevenly reducing your tire’s lifespan.