I am a newbie car driver (I got the license few days ago). I am about to get a used car and I am perplexed regarding which one to get. My concern at the moment is what is the maximum mileage that I should stick to. For example, if there is a BMW 318i (Oct-2004) with 138500 km, is that OK? is there a rule of thumb for the OK mileage?
The mileage of the car doesn't matter as people can get the mileage reversed. Which make the buyer dumb infront of them. I sugget you Look for the obvious signs like the head-gasket's condition, any oil leaks, try looking at the under-frame,signs of rust,check the relay box.(reason, because the relays are long lasting in most cases,and if they're replaced means major issues in the past.)then you can check the chassis number,confirm it with the local bmw center(in your case).
For a car of that sort of age, mileage is much less important than condition. Read through the guide Anarach posted in his comment above, and other online guides - ideally find one that is relevant to the make and model of the car you are looking at, as many models of car have particular issues to consider.
In the UK, the 'average' driver drives 10-12000 miles per year, so I'd be looking for a car to have done around that - so a 10 year old car would have done around 100 - 120000 miles (160-190000km), but obviously this varies per country. I'd avoid any car with a suspiciously low mileage as noted in Saad's answer. Check the car's history where possible to see if the numbers add up...
The best advice I can give is to take a more experienced/knowledgeable friend with you - no only will they be more likely to spot any problems, but the salesperson is less likely to lie to someone who appears to know what they are talking about, whereas a newbie buying their first car is, unfortunately, an easy victim.
Since different makes and models of vehicles have so much variety, a good bet would be to visit a forum dedicated to enthusiasts of that particular model of vehicle. Most likely you will be able to find a thread in any decent sized forum that talks about precisely what to look for on that model. Things are often common failures on specific models, like the aluminum intake manifold on the 5.4L Ford Triton engine in the first generation of Expedition had a tendency to crack.
The E46 (the BMW you mentioned in the original post fit s in the E46 family along with all other 3 series BMWs that were developed at about that time) has a history of water pump failure, various electrical issues are also fairly common, but all in all they hold up well