A heart attack occurs when there is a blockage in the blood supply to the heart, leading to damage to the heart muscle. On the other hand, heart failure refers to a condition where the heart is unable to pump enough blood to meet the body's needs. Heart attack can be a major cause of heart failure.