From what you describe, it sounds more likely that it was a Sudden Cardiac Death.
What happens is that something causes sudden loss of cardiac output (blood from the heart under pressure generated by the heart's left ventricle) to the brain - and when you suddenly lose cardiac output, you black out. Forms of loss of cardiac output include basic fainting (vasovagal attacks), collapse due to severe aortic valve stenosis (narrowing of the aperture of the valve leading from the heart - when it is too narrow then not enough blood reaches the rest of the body - under stress it can lead to collapses) and uncommon, sometimes fatal arrhythmias that lead to complete asystole (flatline - the pacemaker region of the heart doesn't work) or ventricular fibrillation (the conduction throughout the heart's pump region, or ventricles, is so disorganised that the blood doesn't move). It can often happen without warning, without even chest pain or palpitations beforehand.
Sudden cardiac death is usually due to ischaemic heart disease, sometimes occurs as a result of congenital heart defects, but can also occur in otherwise healthy individuals as a result of inherited disorders such as cardiomyopathy (particularly hypertrophic cardiomyopathy where the heart muscle is abnormally big, causing pump failure [analogous to squeezing a lemon with a boxing glove], as well as cardiac demand outstripping coronary supply), long QT syndrome, Brugada syndrome, etc. Sometimes, the telltale feature is a strong family history of unexplained death at a young age, and if there is this suspicion and a confirmed diagnosis then family screening is strongly urged.
The way the brain controls the heart is as a balance between sympathetic nerves (telling the heart's pacemaker region - the sino-atrial node - to speed up) and parasympathetic (slowing it down) input from the vagus nerve, based in the medulla at the bottom of the brainstem (near the reticular network that controls consciousness, and also affects other autonomic systems such as breathing). However, the heart itself is a unique organ, and the arrangement of cardiac cells and conduction fibres such that they can continue beating without external nervous input. Theoretically if the connections were damaged in a sudden way, most likely by a sudden new pathology in the medulla such as an acute stroke, then the heart would revert to its own self-regulatory heart rate, which by default is slow enough to cause loss of normal cardiac output. However, such an occurrence, of the heart suddenly stopping due to the brain's control over it failing, in someone who was previously fit and well, is something I've yet to come across.
If there is such a situation that the pacing of the heart is malfunctioning, then depending on the aetiology and type of heart block, an artificial pacemaker may help (and there are several types for pacing the atrium, the ventricle, both, or even the atrium and both ventricles). If there is a condition causing rapid palpitations leading to this, ablation therapy is useful if the usual antiarrhythmic drugs don't work. ICDs are also useful for those with refractory ventricular arrhythmias, zapping the heart back to its usual rhythm. However, these are only really reserved for people who have had a problem identified, and once identified then it might be of benefit.
As for performing CPR, well, CPR definitely saves lives, but in practice is usually unsuccessful due to various circumstances, whether it's due to underlying pathologies in that patient, poor condition before the cardiac arrest, poor identification that the patient is about to arrest (these peri-arrest situations are something that today's ALS courses are focusing on strongly: preventing a very unwell patient from going into cardiac arrest is seen as just as if not more important than treating cardiac arrest), inadequate or improper CPR, or simply that in someone who was otherwise normal, it catches everyone by surprise. (At least in hospital with in-patients with medical issues, there's a half-expectation that the patient could deteriorate and that there are trained staff to resuscitate him, but even then we get caught out.)
I'm not sure what underlying medical conditions your friend had, but if that person was previously fit and well, with a history of death in the family at a young age, then sudden cardiac death due to whatever cause was probably the most likely reason, and it is usually a good idea to have the family screened for inherited heart disorders.
I'm sorry for your loss. I hope this has been helpful.