They’re in your long-term memory pretty much right away. Put a block of five digits in you head, say 6 8 5 3 3, and commit it to memory. Now count backward from 100 by 3s. What were the five digits? If you remember, then they’re in your long-term memory. (Obviously, this exercise is a silly example because the numbers are on the screen in front of you; but the point is the same.) Short term memory is like a temporary cache, or maybe a working cache, that gets cleared off after a few seconds if you aren’t actively using it.
How does it happen? I don’t know. I only know that the hippacampus (sp?) is involved.