Heart blocks usually build over a time of months and form due to various risk factors like family history, high cholesterol,
diabetes, hypertension, sedentary lifestyle, etc. Sudden heart attacks usually occur in these cases during sports/gym/performances due to stress and dehydration as these promote further constriction of the heart vessels and clot formation.. That's the reason hydration is so important during exercises and marathons..
That explains a sudden heart attack in a young and seemingly healthy person. The best ways to prevent it are by maintaining a healthy lifestyle, stress control, adequate hydration and by undergoing regular health checks.