Answer:
you can recognize these patterns when they recurring over and over
once you see these patterns confront the person about them not causing because that might escalate the situation onto something that is unnecessary but ask about why he/she is doing these things.
just ask if they are ok and let them know that you are there for them and they aren't alone because there is always the possibility that being alone will make it worse for that person.