the most SEO friendly way to redirect
The most SEO friendly way is probably not to redirect at all - unless perhaps the user has already made a specific choice (during their session).
...they get the Hungarian site by default.
Search engines need to be able to crawl both versions - so they cannot be forced (defaulted) to one or the other.
You need to make sure you have implemented the appropriate HREFLANG tags so the search engines know about the different language versions. See Googles' help docs: https://support.google.com/webmasters/answer/189077?hl=en
I 301 redirect my main page permanently to two different pages at the same time.
This isn't a "permanent" redirect. Users can presumably change their mind (or a different user uses the same computer/browser) etc. So, if a user has already made a choice then a temporary (302, 303 or 307) would be more appropriate.
If a user follows a result in the SERPs for example.hu/en
then they should not be redirected, even if their language preferences are set otherwise.
UPDATE: From comments, it would seem that:
- The current language redirect only occurs on the document root. ie.
example.com/
. Other URLs are not redirected.
example.com/
and example.com/hu
would otherwise contain the same content.
- The document root
example.com/
is not considered a canonical URL (it doesn't appear in the sitemap).
From this I think a 302 (temporary) redirect is perfectly OK. I would a avoid a 301 (permanent) simply because you don't necessarily want users to cache the redirect.