1. When the phone rang, I came in. (This means I might have heard it from outside (for example) and came in to answer the phone)
While the phone was ringing I came in. (This means it was a coincidence.)
2. I am sorry that I was late. However, this is not commonly used. I, personally, say: Sorry for being late.