When your friend is spectating another user, then you click to spectate your friend and automatically starts spectating the user your friend is spectating. If your friend stop spectating that user you keep spectating that user.
example:
User X is spectating user Y. User Z clicks to spectate user X, then automatically starts spectating user Y. Player X starts spectating user P, but user Z keeps spectating user Y.
examples with pictures: