The mystery has forced two beaches in southern Australia to close as scientists investigate the cause of the foam.