The first few chapters of 'Inverting the Pyramid' by Jonathan Wilson discuss the spread of football (or soccer) to the rest of Europe and to South America by British emmigrants in the late 19th and early 20th centuries.
But why did football not take off in many of the countries that were British colonies at the time (e.g. India, Pakistan, Australia, NZ, West Indies) - or, at least, not to the same extent as in the two 'traditional' footballing continents? And why were other British sports like cricket and rugby exported within the empire more successfully? (Or am I understating football's relative popularity in these countries?)
I can only speak to America, and the popularity of "Gridiron" Football and Baseball as opposed to Association Football, and Cricket. Someone else will have to fill you in on the other former colonies.
Speaking only to football, it was because of college. I believe that in England, rugby has always been a very popular game at the elite public schools (I recall a quote saying "Soccer is a gentlemen's game played by thugs, and rugby a thug's game played by gentlemen") and it crossed the Atlantic in the mid-to-late 1800s, and found its way to the elite Ivy league schools. Originally, they were playing essentially rugby, but the rules evolved over time. The number one person responsible for this was Walter Camp, who pretty much wrote the rule book for american football.
Before Camp, each school had its own rules variations, some more like rugby as we know it, some closer to the modern (American) football game. Schools would also play against Canadian teams occasionally, usually McGill University. Generally speaking, you played by the rules of the host school, but this obviously was problomatic. Camp led the committee to agree on a set of rules for everyone, some times in the 1870s. He is responsible for the line of scrimmage, as well as the 11-man sides (originally it was as high as 25!).
The game was further changes in the early 20th century because so many people died playing it! President Roosevelt supposedly had to intervene and say "do something about this, or the game will be banned." This resulted in the introduction of the forward pass so make the players spread out more.
So anyways, at this point, we have a game that over 30+ years has very much changed from its Rugby origins, and is amazingly popular on college campuses. It long since expanded from its Ivy League (although the Ivy League didn't actually exist yet we should point out) origins and was being played nationally at schools both big and small. And it was popular. And it kept growing. East Coast to the Midwest and the West Coast, and then into the South. By the 1930s it was everywhere. But the college game was much more popular than the pro game. The NFL, founded in the 20s, was originally just a regional thing in the mid-west, and many college stars didn't even go to the pros after.
It wasn't until the 1950s, and the introduction of television, that the NFL really took off. The 1958 NFL Championship game (this was before the AFL and the Superbowl) between New York and Baltimore is wildly credited as being the "birth of the modern NFL" since it was one of the first nationally televised pro football games. And from there is just kept going.
Hope that helps! I'll leave basketball and baseball to someone else.
Sources on this: Some is just stuff I've picked up over time, but primarily I'm drawing on three books I have read on this topic (I am doing it off the top of my head since none are handy at this moment. Any errors are to my memory, not the author). The Big Scrum by John Miller; The Glory Game by Frank Gifford; and The Best Game ever by Mark Bowden.
Baseball evolved over much of the 19th century, but if you want to pick any one point of "origination", the American Civil War is where what we think of as baseball really started to appear.
Bat and ball games had been around for ages, being played in Great Britain for centuries, and they no doubt came to America from there. Cricket, baseball and rounders all have their origins somewhere back there.
Now, with baseball specifically we start to see regional variations that kind of, sort of resemble baseball being played in America in the first half of the 19th century. The Knickerbocker rules - which date to 1845 - were the dominant set of rules being played in the area of New York, but they were by no means the only set of rules. The game would be kind of recognizable to a modern observer, but rules such as making an out on a catch after one bounce would be pretty weird now. It also lacked 'balls', although three strikes was a rule.
Now, as I said, the Civil War was a key component of the rise of baseball. When the war started, hundreds of thousands of Union soldiers from all other the country found themselves camped together and with a lot of downtime. Baseball became an exceptionally popular game for them, and with New Yorkers everywhere, the Knickerbocker rules found themselves to be the most popular used, essentially becoming the de facto rules for Union Army baseball. When the war ended and the Army disbanded most of its men, soldiers headed home, bringing with them either a new game, or else a new set of rules for one they had already played.
In the wake of the war, amateur athletic clubs started sprouting up all over, and within only a few years, the first Professional club was founded in Cincinnati, in 1869. More clubs followed, and in 1876, the National League was founded (It was not the first league though, as there had been a pre-war association, the NABBP, that governed amateur clubs in the New York Area). The rules continued to evolve beyond that point - here is a handy list - but by 1889 or so (with the introduction of 'four balls'. It had been as high as nine in the past) I would say the game very much resembled what we have today.
So there you go, as with most games (Basketball is the only one I can think of off hand that was essentially created out of thin air), it was a slow, evolutionary process from earlier ones. That being said, the most important point in its development was the American Civil War, which not only helped to speed up standardization of the rules, but created a nation wide network of fans and players.
Hope that helps. Any questions, glad to fill in any gaps there as much as I can.
there were a couple of related questions a few days ago; check them out for previous responses & links to loads more previous posts: