However, without noticing it, I generated a address to the wallet which would be sending bitcoin, instead of the one receiving it. I just forgot to select the other wallet in bitcoin-qt.
That is correct. Transactions to an address that is in the same wallet shows up as N/A on the address column.
So the bitcoin was sent to the same wallet, and now have 0 confirmations forever. It appears as "n/a" in the transaction ledger, instead of the address. Also a segwit change address was generated.
Not forever, likely just unconfirmed.
Minutes later I tried to send this bitcoin (0.12 actually) from these both adresses (the legacy and segwit) to another new legacy adress in the other wallet. This time I paid attention to it and selected the right wallet.
However, these are both unconfirmed as well. Blockchain.info also shows the first wrong transaction as unconfirmed.
Will these two transactions be confirmed, since the first one (payment to yourself) was not? Or did I lose the money due to this mistake?
My guess is that what you've done is that you've spent the outputs of the first transaction in the second transaction. This means that your second transaction cannot be confirmed without the first transaction confirming. This is not an issue however. If you've signaled RBF, you can try to use abandon transaction as mentioned for both transaction and spend it again with a higher fee if it is not in your mempool and it likely is.
I'm not sure if Bitcoin Core allows the RBF to have different outputs. IIRC, it doesn't so that could be a problem. Should try to create a raw transaction in that case, with care.
start your wallet with -zapwallettxes
Zapwallettxes was removed in 0.21.0, just in case OP tries it.