In both your second and third sentences we use "do" not "can"
As a general guide we say "do" = for knowing/experiencing/feeling etc
and "do" = for an action, speaking = pronouncing, knowing,understanding, etc
"How do you pronounce this word"
"How do you know that/it/this"
"How do you know he/she/they like you" = your understanding not feeling.
"How can you do that/it to her/him/them" = you did or are doing something to them
"how can you be so cruel to your parents" = he/she/they/them are being (doing the cruel things/acts)
"How can you do that job" = how are you able to do that job.
"how can you be like that" = someone is saying how are you able to be so, kind ,patient, cruel, wicked,evil, nasty, bad, or whatever adjective.
Here is the grammar if you want it.
CAN: = EXPRESSES ABILITY
https://www.thefreedictionary.com/can (WITH USAGE NOTE)
DO: = TO PERFORM EXECUTE OR CARRY OUT
https://www.thefreedictionary.com/DO
NOTE there can sometimes be an overlap with the knowing situation for both "can" or "do"