If it wasn’t the case, people would just step off the pitch to make an (otherwise onside) attacker offside. Think about it
But when has that ever happened. Why should a defending team be punished for having a player off receiving treatment? If a player deliberately steps off the pitch that is a cautionable offence
A player receiving treatment is off the field with the referees' permission and not, therefore, part of the game until and unless that player receives the referees' permission to re-join the game.
Also, you have not seen it happen because the Law currently prevents it from giving an advantage to the defending team. If the Law was not written as it is, you would see it quite often. Clearly, that is only my view; but it is one based on the cynical way in which players and coaches exploit loopholes in the Law to their own advantage.