The Elantra is a compact that split its reputation clean in half at 2021, before that line, you're shopping engines that seize and cars thieves steal with USB cables; after it, you're getting a genuinely competitive sedan with sharp looks and a warranty that backs the turnaround. The 2021-up cars deliver on value and the hybrid hits 40+ mpg without trying, but pre-2021 models carry catastrophic engine failure risk (Theta II bearing seizures, oil consumption) and the 2017-2021s remain theft-prone even post-recall. Buy 2021 or newer if the price works and you want modern features without the baggage; anything older is a gamble best left to someone else.
The Mazda3 is what happens when a compact car decides it's too good for its price bracket, and the interior actually backs it up. The 2.5L engine is bulletproof (owners routinely see 200k+ miles), but the 2019 redesign swapped the old multilink rear suspension for a cost-cutting torsion beam that blunts the handling sharpness earlier models were loved for. If you want a refined daily driver that feels expensive and runs forever, this works; if you want the sporty Mazda everyone raves about, hunt down a 2014, 2018 instead.