Whenever you see paintings depicting revolutionary battles, everyone in the millitia had one these tri-corn hats like this.
I was wondering where did they get these and hats and why did they use them. Was it just that there were a ton in production or were the leftover from sea-faring?
Do they server any actual purpose on the battlefield?
The three-cornered hat (tricorn is a late 19th century term) was used not only for the military, but as a general fashion. It's a basic hat blank which can have one, two, or three sides "cocked" up. The triangle can be any proportion, the brim isn't always even, and other variances allow for a nearly infinite number of styles. Many were named; the mathematical which has equal sides for example. I can't find the print I'm looking for, but here's a similar example of a print showing different fashionable hat styles for men. Hats before styling are unevenly flat and floppy. This not only looks awful, but as /u/DonaldFDraper pointed out is very ineffective for rain shedding. The military issues a particular style of hat (it's supplies, proportion, and trimming all specified) depending on the regiment and part of it's uniform.
The Bi-corn and Tri-corn hat of the 1700s served a purpose of basic head protection (since direct sunlight will wear out a soldier as much as exertion) but also protecting them during weather events (such as rain). Ideally, the tricorn is worn with the point facing to the front and partially up, thus any rain that falls on the soldier will fall back and out of the rear corners. The bicorn does the same except it's meant to be worn evenly.