On Realms (possibly other kinds of servers), if hostile entities (such as skulkers, skeletons, or blazes) are set on a player's team, they will leave the team when the player logs out for an extended period of time and attack him when he logs back on.
Duplicates MC-89610