How to fix sounds from both headphones and speakers at the same time

The solution is simple, just enable automute in alsamixer.

alsamixer