British retailer Marks & Spencer (M&S) said a cyberattack earlier this year was an "extraordinary" moment for the company, nearly wiping out profits.