We look back and think people just started shaving in the year 1900, but that's not the case. The reason we think this is because nearly all of our historical pictures tell us this.
For the most part, men shaved. Nearly all of them shaved. Look on the back of the two dollar bill at the Declaration signers. No beards. In the 1700s, for instance, you had Bluebeard, Blackbeard, etc., with beards, but they were pirates. "Civilized" men did not wear beards and anyone with a beard was looked down upon as a ruffian or worse. A man with a beard was a man who lacked the cultural enlightment of a razor.
Beards were big up until the late 1500s and early 1600s. At that time, it was mostly priests who shaved to indicate celibacy. If they were swayed over to the protestant side in the Reformation and quit being celibant, well, they let their beards grow. Around 1600, clean-shaven was in. Big time. Peter the Great even levied a beard tax, so the Russian men would shave and the rest of Europe not think them savages.
In the 1700s, everybody shaved. I mean everybody. If you had a beard in those days, it meant you could not afford a razor, and couldn't borrow one. Even these wild, manly frontiersmen, like Simon Kenton, were clean-shaven. Lewis Wetzel, who had braided hair down to his ankles, shaved.
The beard didn't come into fashion until the around the Civil War, which just happens to be the same time cameras become widely used.
You can see the beard trend literally in the U.S. presidents. Washington was clean shaven and the next 14 presidents were, too. Abraham Lincoln took the oath of office whiskerless, but grew a beard while in office. Every president between Lincoln and William Howard Taft had a beard, or at least a stache, except Andrew Johnson and McKinley.
By the way, anybody notice how much Martin Van Buren looks like Bill Monroe? Put a white John B. Stetson on his head and a mandolin in his hand and he's a spittin' image.
Your actual question, where they got them? They bought them. They had stores back then. People living in extreme rural areas before the Sears and Roebuck did two things: they traveled to a trading post, or peddlers with a wagonful of clocks, razors, knives, rifles, sugar, all the stuff you need came to them.
By the way, here is George Washington's straight razor. I'll post it in its own thread, too.
http://www.goingtophilly.com/po-razor.jpg