Head gasket on Subaru from before 2002

I’m looking for either a Forester or a Legacy from 1998 to 2000. I’m hearing a lot of things about these cars being prone to head gasket failure. I actually found one which head gasket had been changed. What does this mean? I think it could happen again, right? If the engine heated, it’s warpped and has greatly suffered. Should I try avoiding subarus from before 2002 and look at Toyota RAV4 instead?