How to mix two signals without changing the overall loudness?
That depends somewhat on the application. In most cases a "constant energy" pan will be best. This can be expressed as $$y(t)=\sqrt{\alpha} \cdot x_{1}(t)+\sqrt{1-\alpha}\cdot x_{2}(t)$$ where $\alpha = .5$ is the point of equal energy.

If you are working with fixed point signals, such as wave files for examples, you may run into clipping problems. That could be a topic for a separate question.