While I am learning the American pronunciation, I find that the Americans pronounce the word "shorter" quite differently from the British. Specifically, the "t" sound in the word is pronounced like the "d" sound. Therefore, could somebody help me to explain this? Is there a rule behind this?
First of all, the UK has many different regions, only a few of them where people pronounce the perfect "t". This accent is mainly used by middle-upper class people of the south and most people in the north... until you get to Northumbria, nearly everyone in Scotland and Wales would pronounce the "t" silently and emphasize the "ER". Also there's a place riddled with mis-pronunciations known as Essex, people there will not only skip over the "t" but also make the first "r" sound more like a "w" so the word is vocalized as "SHOW-ur"
The Americans (of all regions) would pronounce both "r" more strongly and turn the "t" into a "d" just like the words: "water", "scooter" "bitter", "mortar", "quarter", "porter" and most* other 2-syllable words that end in "r". The reason I say most is because this is not a rule, rather than a convention to make words flow better for the American accent.
The only times when an American would pronounce a perfect "t" in the middle of a 2-sylable word is when the first syllable is long and/or stressed like the words "laughter", "after", "shifter", "master", "hunter".
The paragraph above however, is subject to region in the US where people in the south make the middle "t" much shorter or turn it into a d and people in the north would pronounce it as a perfect "t"... Again this is just for the sake of flow, once you start pronouncing certain words with your regional accent, it just feels natural to pronounce all words in a manner than makes them flow. This is what gives people the ability to "put on" a totally different accent than their own and make it sound authentic.
I believe the answer has to do with how the "r" that precedes the consonant "t" is being produced in American English (EDIT: when saying the word shorter as distinct from saying the word carton).
The American "r" can be produced with lips nearly pursed (imagine a goldfish), and that constricted mouth position causes the "t" to move from unvoiced dental [t] towards voiced dental [d].
The british "r" is produced with the cheeks tauter and drawn slightly back, and that mouth position is more amenable to an unvoiced dental [t].
I'll add a little bit to Jonas's answer. Americans, when a t is both preceded and followed by either a vowel or a voiced consonant, will tend to voice the t as well, thereby turning it into a sort of a d sound, especially when speaking quickly. (Note that er is a type of vowel sound.) You'll notice that all of the examples that Jonas gives in his second paragraph are words of this type.
The only exception I can think of to this is the word potato, which I pronounce potado. (When I lived in England as a boy, and used glottal stops to pronounce t's, I said pota'o, so there's an analogue there.)
Now, in the case of nt we tend to leave out the t altogether. So I disagree with Jonas in how I pronounce hunter: I tend to pronounce it hunner. Also twenty becomes twenny.
If you want to get further into British English, you might want to look into Received Pronunciation (RP).