The E36 M3, and BMWs in general, are pretty reliable cars and can take some abuse (ask me how I know

!!). But like what was said earlier, it is the past history you need to take a look at, if the info is available.
At a minimum, take the car to have it looked at by an experienced BMW tech, even if you are going to buy it from a BMW dealer, but especially if you are buying it from an individual or a used car dealer.
Price on parts are higher than Japanese or domestic cars, but you can still get parts cheap if you know the right place to look (I can help you out with that). If the car has a factory CPO warranty, then take it to the dealer to get warranty work done. If it has no warranty, then I would stay away from the dealer. I am not sure where you are located but I know 2 good independent BMW shops in the area.
The area where things can get expensive is modifying the car. For example, a supercharger system for a Mustang may be $3000 but for the M3 it would be closer to $6000 (and lets not get into turbos

!!). The only tuner I would personally stay away from would be Dinan. They make good stuff (most of it anyway IMO

) but it is grossly over priced and you can get the same performance from other tuners for much less (I can also talk to you about this).
To get an idea of some common mods for an E36 M3, take a look at my sig. There are not too many things left fo me to do on my car (but I can always find more

!!). Trip can vouch for my car since he has seen and driven it. Good luck!