The ruling provides temporary relief for 21 states seeking to stop the Trump administration from ending federal funding to hospitals that provide gender-transition care.