What you said is true, because every player has a contract with the team that signed them, so no player can just leave to any team they like if they're still under contract with their old team. However, being loaned to another team is different, as that team may already have more players for a particular position, so it wouldn't affect the loan move. I've also seen no news about Leroy Sane returning to Bayern Munich after being signed by Galatasaray last month.
Except for a loan, a player is not going to exit a team just like that when they have their contract still on, that will be a bridge of contract which comes with some penalties, meanwhile we need to look at the fact that Bayern Munich is his original team and he will have to return from the loan before making his transfer move to the new team where he has been signed, Bayern much has got good replacements for him so his exit may not get to affect Bayern Munich so much after all.