Why do you have American and british accent?

Imagine a group of people who live together and speak the same way. Any change in the way they speak (their dialect) will either pass to the whole community, or drop out of usage.

Imagine some of those people move elsewhere and start their own community. Each group may develop different slang and dialects that spread through their own communities, but not to the other one. Two different dialects have been born.

This is why Britain itself has many accents, so it's no surprise that when some of them colonized what is now today the US, that those people developed their own too. Another important factor is that the US took in a large amount of Irish immigrants, their dialects combining with the current residents to form the US accents used today.