How is asymmetric cryptography safe if one of the keys is public? Let's suppose $A$ is sending a message $m$ to $B$ using asymmetric cryptography.

To guarantee the authenticity of a message, $A$ encrypts $m$ with $A$'s private key: $E(m, k_A) = m_A$. 

Then, $A$ sends $m_A$ to $B$.

$B$ can check that $m_A$ was sent by $A$ using $A$'s public key $p_A$, by doing $D(m, p_A) = m$.

If the public key $p_A$ is, by definition, public, if an attacker intercepts the communication and get $m_A$, he could easily find $m$.

How is asymmetric cryptography safe under these conditions?
How is asymmetric cryptography safe under these conditions? 


Well, you sort of outlined (but see kelalaka's corrections) how you would use asymmetric crypto to do authentication; that is, to make sure that the message was actually sent from $A$.

You ask "how does that provide privacy?".  The answer, of course, is "if that's all you do, it doesn't".

If we want to do privacy, that is, generate an encrypted message that only $B$ can read is that $A$ encrypts $m$ with $B$'s public key, that is, $E(m, p_B) = m_A$.  We then send $m_A$ to $B$.  $B$ can then take his private key and compute $D(m_A, k_B) = m$, recovering the original message.  No one else can read the message, because only $B$ knows $k_B$, and that's needed to decrypt the message.

Two notes:


If we need to provide both authentication (only $A$ could have generated the message) and privacy (only $B$ could read the message), we do both; $A$ might generate the ciphertext $E(m, p_B) = m_A$, and then sign it with his private key $Sign( m_A, k_A ) = s_A$ and then send both $m_A$ and $s_A$.  $B$ can then verify the signature (with $A$'s public key), and then decrypt the message (with $B$'s private key).
In practice, if we need to encrypt a long message, what we generally do is pick a random symmetric key (which is short), and use the public key encryption to encrypt the key, and then use the symmetric key to encrypt the message.  Symmetric encryption is far more efficient than public key crypto, and so this is a significant performance gain over using the public key encryption method multiple times to encrypt the message.