It's not like that. This isn't a "subaru problem", with a few minor caveats I'll get to in a moment. Rust is about exposure to caustic chemicals used all across the northeast, midwest, and a few areas out west (apparently yours, or your car came from somewhere else that did in the past). Year/make/model is not the right question to avoid rusty Subarus. That's why there are plenty of rust free old Subaru's out west and down south.
There are a few variables like minor weather advantages, Subaru's are low to the ground so are closer to caustic chemicals and have tight unibody parts that hold them better/longer. And they are simply USED in the snow, and see caustic chemicals. Very few Subaru owners avoid snow or have a 2nd vehicle for winter driving like german car or garage queen truck/jeeps. But those aren't a big deal - it's mostly about exposure to caustic chemicals which can be avoided if you search down south and out west like Portland, Seattle, Colorado, and see 1980's and 90's Subaru's with zero rust.
it doesn't matter. Simply put - avoid the 1996-1999 DOHC's and all the rest are about the same in terms of practically considering cooling/headgaskets.
Ej251/253 - The differences were minor 10 years ago and the nail is on that coffin 20 years later due to age. The "EJ253 improved cooling" comment should be entirely ignored for a litany of reasons that I don't have time for and would require logically and statistically pointing out the absurdity of all the internet hypothesis, guesses, and anecdotal points over the decades that you'll see searching online.
Factory installed gaskets usually leak externally so there's little chance of stranding events. They usually leak externally and get worse over 10's of thousands of mile. This means they aren't prone to multiple serious overheating events like the DOHC. In those terms, and due to age, all the post DOHC EJ25's are practically the same when considering buying 15-20 year old ones.
If they leak - use a Subaru MLS gasket, torque specs, resurface the heads, clean the block properly, and make sure all bolts and threads are clean and lubricated when torquing.