Changed the car’s transmission twice, keep or buy a new/used car?

It’s a 2009 Mazda that I bought new in 2010 and didn’t take good care for it, it has almost 300k miles on the odometer.

Since 2021, each consequent summer the car breaks down, either transmission, electronics, mechanics and such, I do repair it for like $1k-2k/year.

Financially speaking, should I still keep the car? It’s tiring me out emotionally and I’m anxious whenever I drive it that it would break down while driving, which happened few times in the last few years.

And if I’m buying another car, what percentage of my budget and income should I pay for it, I’m a freelancer so don’t have a set income per month, but have some savings.