The issues with 911 are there but overrated happens to an estimated 2% of cars. All depends how its been treated so buying a second hand one is risky as a lot of people don't let them warm up and they struggle with oil starvation and that leads to all number of issues. Hammering the car from low temps leads to lots of damage, but I would get a warranty and make sure you get a good one if it doesn't cover up to 12k forget it. If you need an engine replacement then thats the round about cost.
The more miles you do the better, there was a study in total 911 of a group of 996 carreras that were used only for track days and race driver training at Knockhill. All had over 70k track miles which is a huge huge amount. Not one had an issue with IMS/RMS. Because the cars are thoroughly warmed up, no short drives etc so by using them the likelihood of a problem is smaller it seems to happen on relatively low milage cars that get the odd run out, but run hard and spend most of their time sat in the garage.
The S54 in the M has the similar and well documented issues, catastrophic engine failure is just as much of a risk, its the problem with all high performance engines with small tolerances. Everytime the 911 goes in for servicing they do a full oil breakdown and if there are any fragments of metal the they swap out the bearing. The RMS seal is checked every major service. Porsche will tell you that it cannot be checked without removing the engine but most Porsche specialists can check it without taking out the engine with special tools designed just for the job. RMS is a tough one because oil leaks internally so you can't tell. A lot about looking after one is about knowing the problems and treating the car as such. Be that if there are fragments of metal upgrading the bearing there are many companies with upgrade bearings.
The M is similar the half shaft bearings should be replaced by the user between 80-100k to ensure they don't start wearing and causing the same issue with fragments of metal in the oil destroying the engine. As the car gets up to that milage having an oil check and the next service is a good idea to figure out the issues.
My dad has a 2007 911 997 CS awesome motor very similar performance wise to the Z4M but the drive is in a different league IMO, but the Z is half the price so the Z is the bargain of the sport car world. Lovely car something about the way it drives like no experience Ive had.