I've owned multiple e46's with the 2.5L straight 6 M54, I believe that year X5 has the 3.0L straight 6 M54. So it should essentially be the same engine but with a slightly larger total displacement. I took mine apart and put them back together dozens of times almost blindfolded, so I may be able to help if you have specific questions about what's under the hood.
I really would not recommending buying one of these without being familiar with the platform or if the seller has extensive maintenance history, but since you already own it: For reference here are the common maintenance topics once it passes 80-120k total miles (US miles not Km)
- Cooling system typically turns to glass after 80k, i.e expansion tank, upper cooling hose are both made of a material that works great but basically become so fragile that they'll bust after 80k as soon as you touch them. Plan to buy the connecting clips too, they're a plastic that harden and shatters. The water pump and pulley are also ideal replacements after that mileage. The radiator loves to blow a hole in it somewhere around this mileage too so that's something to watch. The M54 can handle a lot of beating but allowing it to overtly overheat will murder it the same as almost any other engine.
- valve cover gasket, tends to also turn to glass from rubber after this amount of mileage. Could cause a nasty misfire but should be easy enough to replace. Did it thrice on my e46's and cost $25 for the gasket and 2-3 hours of labor (did it myself, any dealer or shop will murder you on a 10+ old bmw, short of a blown head gasket I would 100% recommend wrenching yourself as parts for these aren't too expensive but labor will run you $1000's)
These engines themselves are almost bulletproof, but all of the accessories and connecting items and electronics are almost infamous for just killing themselves after 100k on the odometer. If someone tells you "lol old bmw must be hard to work on and not cheap" they're probably a mechanic trying to take you to the cleaners or just buying into the stupid "lol European car" memes. As long as you're willing to do the work yourself and learn about the car, parts are fairly cheap and the work isn't anything much crazier than any US car I've ever owned. They're incredibly fun to drive and own and I'd highly recommend one to someone looking for a fun car with the asterisk of being willing to work on and learn about the car. If you just need an A-B car for work I wouldn't recommend a 15 year old BMW. But most models produced between the late 90's - Mid 00's are a great mix of mechanical/eletrical, anything not-new post 08 without a warranty would probably be a headache unless you really don't mind some wrenching and love electrical gremlins
I will say that if you aren't willing to buy some tools yourself as well as do the regular maintenance yourself, this is not a pre-owned car to own, any German car mechanic will absolutely drain your bank account on labor for a 17 year old BMW. Parts here in the US are pretty cheap, I think the most I've ever spent on a single part was $200. But that's with me doing all of the maintenance work myself.
If you have any more specific questions about the maintenance or common issues I'm happy to try and help