I think this has been addressed before but I think there's twothings that need to be covered: there wasn't one style of hat in the 18th century and they typically just called it a cocked hat -because you cock up the sides of the hat into the classic shape.
Thing is, it was never one consistent shape or style throughout the century. Earlier on in the century, you'd see taller brims that sort of resemble the kind of "cavalier" hat that was predominant in the 17th century, some of the equidistant in angles, and then as the century goes on the brim tends to shrink and the overall shape changes with it. The style of cocked hat that was worn in the 1770s by someone like George Washington would not be the same hat from someone in the 1720s, much less the 1790s, where the more bicorne shape was becoming popular along with early top hats. Your class and job can also influence the style hat a gentleman would wear, a sailor wore a different hat from a clergyman. Here is a picture of different styles of hats around the mid-century or so, showing different classes and styles of hats. This link shows a few differnt examples of extant hats from the century, I think they mainly lean towards the latter half -even then it shows a huge different in stylings. This exhaustive slideshow from the 18th Century Material culture center shows a lot of extant examples from the late 17th to the rest of the 18th century, you'l see a lot of changes as the brim shortens down and fans out in general shapes.
As to why it went out of fashion, there's few likely reasons. One being that fashion is fickle and changes; two the military swapped from the bicorn shape in the 90s to shakos by 1800 to copy more eastern military like the Hungarian Hussars. The tophat had a prototypical shape in the 1780s with a taller crown and small brim, eventually coming to the more classic shape by the early 1800s, replacing the cocked hat for the most part.