You would be shocked at the amount of shows that were sold to NBC but produced by ABC Studios or whatever. It still happens today but the trend is going back to the closed loops.
Two immediate examples I can think of:
“House MD” was produced by NBC/Universal but aired on FOX
“For All Mankind” was produced by Sony but currently airing on Apple TV+
If a different studio was selling to Apple/Amazon/etc then presumably they would have language that lets them sell to someone else if they did not end up distributing it.