Watchdog did not have proper basis for decision to write down SFr16.5bn of AT1 debt as part of rescue deal, judges find