Transformation is a method of putting DNA (either unaltered or engineered) inside bacteria. There are a couple of standard ways of doing this: Heat Shock and Electroporation.
It's funny how no one really knows how the heat shock method of transformation works. While doing my thesis, I had found this little article that some researchers from West Bengal had written. I think it's a cogent explanation for the phenomenon.
First off, you can't use any old bacteria for this process. In nature, there are some bacteria that undergo natural transformation, but-- as far as I know-- your garden variety (or maybe I should say Lab variety) E. coli cannot be used this way. You have to make the cells competent using Calcium Chloride and a little bit of black magic. My old PI told me that making competent cells was something of a dark art. Anyhow, I am digressing.
The standard protocol for heat shock (in E.coli) is as follows:
1. Mix 40 microlitres of bacteria with about 2 microlitres of DNA (the volumes vary).
2. Leave them on ice (in an eppendorf tube) for about half an hour.
3. Place the cells in a water bath at 42 degrees celsius for 45 seconds. However, this time varies for different competent cells and it ranges from 30s-1 min. I have also heard of people doing it for 2 min.
4. Get the cells out of the waterbath and incubate on ice for 2-3 min.
5. Pipet the bacteria/DNA mix into about 900 microlitres of LB or whatever you're using as culture medium. Caution: don't use the selection medium yet.
6. Place the liquid medium with the bacteria in it inside a shaker at 37 degrees Celsius.
7. After 50 min. pipet 10-200 microlitres of the liquid culture onto an agar plate with selection medium and grow overnight in a 37 degree Celsius incubator.
Now why does this process work? The Bengali researchers claim that it's because when you first cool down the bacteria on ice, they release lipids from their cell membrane in an effort to increase the fluidity of the membrane since it tends to reduce at cold temperatures. This causes pores to form on the membrane surface which can be visualised using SEM. The heat shock step apparently depolarises the membrane which tends to be a little negative on the inside. Now, I haven't read their paper. I only read the abstract. However, I know that DNA is negative and the depolarisation of the membrane may eliminate the electrostatic repulsion the DNA would have faced otherwise. I don't know if this is exactly what they're proposing, but you can find out if you want to shell out some money for their paper. (http://www.ncbi.nlm.nih.gov/pubmed/18651316).