A submarine has exploded in India in what a defence analyst has called "the worst accident in the country's naval history".