As others have stated, you can look for some telltale signs. I personally wouldn't buy an M3 (or most cars) with mods, especially performance mods. That can be a sign that someone was looking for, and consistently used, max performance...
Otherwise, look for little things. Is the interior scuffed up? Are there door dings / scratches etc. on the outside? That can give you an idea.
Otherwise though, I have a slightly different view on buying used, it's been positive for me. I bought the M used, the two cars before that were purchased new, the two before that used. All ran well and were great cars.
In the case of the M, bought it with 19k miles at about $30k below MSRP so someone else ate the major depreciation, and it was close to flawless. I would advise getting one that's certified, so it's under warranty to 100k miles.
2009 E93 M3 - it's, um, pretty fun