I was wondering how could a fediverse software make it so that if a user logs in an instance he is automatically logged in every other instance that he visits.

I think for this every instance would have to share the credentials and cookies with each other. So for example when a user registers the information is shared with all instances to store that user.