The thing is, you can have your cake and eat it too. Yes a modern racing thumper is an expensive project and if you were to go that route, the only answer is the 450 class bikes. The 250 class bikes are just wound too tight and when they go boom, it takes your wallet with it.
On the other hand, a 2-stroke is more predictable expense wise. Reading the manual, they all say to change a piston every 5 races but really, if you are changing you oil and filter every ride and not overly pushing it, you can go a year on a piston and ring! But it still ain't cheap. Used bikes will invariably need a bottom end job eventually. You are looking at a minimum $300 for that (I just spent $750 before labor) and like the 250F, if you have a catastrophic failure, it could be too expensive to repair. I have a 360 Husky taking up space in my garage with no motor because it broke a rod and the loose end spun around the case with the crank, destroying everything in its path!
That's the bad news, the good news is that if you just wish to trail ride with your buddies with the occasional foray into a motocross event, there is a long list of both 2 and 4 stroke bikes to choose from that are cheap, super reliable, and will make you a better rider. What they are not though is 'sexy'. Your friends will point and laugh and tell you to get the latest hand grenade or what 'Ryan' rides. On the other hand, when you smoke them on your 'trail bike', you will have a greater satisfaction, and if you don't, you can always blame the bike.
Kawasaki KDX - Jeff Fredette has won more ISDE Gold on these things than anyone else has even ridden the ISDE!
KTM 200EXC - Shane Watts dominated...I mean completely smoked everyone in the GNCC's on a box stock, off the showroom floor bike in the late '90's/early 2000's.
Honda XR250+ - Any of these models are great bikes that will last FOREVER. When man destroys all life on the planet, the next aliens will land and find an XR that still runs. That is if there are any left that have not been modified. Then they are hand grenades like the modern bikes. Scott Summers kicked ass until he broke his femur. He stayed on the XR even after Honda had the CRF!
Suzuki DR/Kawasaki KLX line - Pretty reliable hound dogs. Similar good looks to the MX'er's, just not wound so tight.
...and basically any of the KTM/Husky/'Berg/TM/Gas Gas (etc) Enduro bikes. These bikes are made to be fast but have to be super reliable to even be considered competitive.
Any used bike is going to need things. Suspension bearings and seals wear out, spokes come loose or stretch. Sprockets, chains, fuel petcocks, cables, carburetor slides, brake disks all eventually need attention. Of course, new bikes do too but you don't usually have to think too much about it until they are used up - which is why they are USED bikes.