I've actually written responses on the origins of both these sports before! Football and Baseball
To give you a super quick run down of what you will find there though, it is kind of a coincidence, although some social historian might be able to point to some underlying factors which made leisure sports particularly appealing in the post-Civil War era). Baseball exploded from a regional sport to one with national prominence due to the Civil War, where the variant popular in New York, the Knickerbocker Rules, became popular entertainment in camp. After the war, veterans brought the game home with them, and clubs started popping up all over the place, and pushing out other variants of batt-and-ball games (Cricket for instance, which had some popularity in a few cities).
Football on the other hand was spread by college students, it first arriving in a much more rugby-esque form, and diverging into a totally different game due to emphasis on different characteristics. College football remained the more popular sport for a long time, and the pro-leagues were secondary for a long time. The rise of the NFL to the place it now holds is generally credited to the 1958 Championship Game, which was broadcast nationally, and a real nail-biter apparently.