I'm looking at a vehicle with 164k miles for 7 grand.
Is that a good price? And is it worth buying with
that many miles? How long before I would need to
replace engine or transmission?
I would not do this. Too many miles.
It's a fair price for the mileage, but maintenance will be high if you don't work on vehicles yourself. Expect to get 200K out of it before major components start failing. That is if the suspension and other parts were already swapped out at around 120K.
It has already had the engine, water pump, and all belts and hoses replaced with factory replacement parts. Would that change your answer?
A new engine makes a difference if it was rebuilt properly. Have the car checked out by a BMW mechanic. Get all the repair and maintenance records if you can and have the mechanic take a look.